lib/celluloid/pool.rb in celluloid-0.9.1 vs lib/celluloid/pool.rb in celluloid-0.10.0
- old
+ new
@@ -1,19 +1,21 @@
module Celluloid
# Pools provide groups of actors which can service requests
class Pool
include Celluloid
trap_exit :crash_handler
+ attr_reader :max_actors
# Takes a class of actor to pool and a hash of options:
#
# * initial_size: how many actors to eagerly create
# * max_size: maximum number of actors (default one actor per CPU core)
# * args: an array of arguments to pass to the actor's initialize
def initialize(klass, options = {})
+ raise ArgumentError, "A Pool has a minimum size of 2" if options[:max_size] && options[:max_size] < 2
opts = {
:initial_size => 1,
- :max_size => Celluloid.cores,
+ :max_size => [Celluloid.cores, 2].max,
:args => []
}.merge(options)
@klass, @args = klass, opts[:args]
@max_actors = opts[:max_size]