Class: Concurrent::Actor
- Inherits:
-
Object
- Object
- Concurrent::Actor
- Defined in:
- lib/concurrent/actor.rb
Defined Under Namespace
Classes: Poolbox
Constant Summary
Constants included from Runnable
Class Method Summary collapse
-
.pool(count, &block) ⇒ Object
FIXME: duplicate the block (thread safety).
Methods included from Postable
#<<, #forward, #post, #post!, #post?, #ready?
Methods included from Runnable
included, #run, #run!, #running?, #stop
Class Method Details
.pool(count, &block) ⇒ Object
FIXME: duplicate the block (thread safety)
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/concurrent/actor.rb', line 86 def self.pool(count, &block) raise ArgumentError.new('count must be greater than zero') unless count > 0 mailbox = Queue.new actors = count.times.collect do actor = self.new(&block) actor.instance_variable_set(:@queue, mailbox) actor end return Poolbox.new(mailbox), actors end |