Class: Concurrent::Actor::Utils::Pool
- Inherits:
-
RestartingContext
- Object
- AbstractContext
- RestartingContext
- Concurrent::Actor::Utils::Pool
- Defined in:
- lib/concurrent/actor/utils/pool.rb
Overview
Allows to create a pool of workers and distribute work between them
Instance Attribute Summary
Attributes inherited from AbstractContext
Instance Method Summary collapse
-
#initialize(size, &worker_initializer) ⇒ Pool
constructor
A new instance of Pool.
- #on_message(message) ⇒ Object
Methods inherited from RestartingContext
Methods inherited from AbstractContext
#ask, #behaviour_definition, #dead_letter_routing, #default_reference_class, #envelope, #on_envelope, #on_event, #pass, #tell
Methods included from InternalDelegations
#behaviour, #behaviour!, #children, #context, #dead_letter_routing, #log, #redirect, #terminate!
Methods included from PublicDelegations
#context_class, #executor, #name, #parent, #path, #reference
Methods included from TypeCheck
#Child!, #Child?, #Match!, #Match?, #Type!, #Type?
Constructor Details
#initialize(size, &worker_initializer) ⇒ Pool
Returns a new instance of Pool.
30 31 32 33 34 |
# File 'lib/concurrent/actor/utils/pool.rb', line 30 def initialize(size, &worker_initializer) @balancer = Balancer.spawn name: :balancer, supervise: true @workers = Array.new(size, &worker_initializer.curry[@balancer]) @workers.each { |w| Type! w, Reference } end |
Instance Method Details
#on_message(message) ⇒ Object
36 37 38 |
# File 'lib/concurrent/actor/utils/pool.rb', line 36 def () redirect @balancer end |