lib/celluloid/pool_manager.rb in celluloid-0.16.0.pre vs lib/celluloid/pool_manager.rb in celluloid-0.16.0.pre2
- old
+ new
@@ -22,11 +22,11 @@
# here except it causes MRI to crash :o
@busy = []
end
def __shutdown__
- terminators = (@idle + @busy).each do |actor|
+ terminators = (@idle + @busy).map do |actor|
begin
actor.future(:terminate)
rescue DeadActorError
end
end
@@ -77,9 +77,26 @@
_send_ :inspect
end
def size
@size
+ end
+
+ def size=(new_size)
+ new_size = [0, new_size].max
+
+ if new_size > size
+ delta = new_size - size
+ delta.times { @idle << @worker_class.new_link(*@args) }
+ else
+ (size - new_size).times do
+ worker = __provision_worker__
+ unlink worker
+ @busy.delete worker
+ worker.terminate
+ end
+ end
+ @size = new_size
end
def busy_size
@busy.length
end