Class: Dynflow::MicroActor
- Inherits:
-
Object
- Object
- Dynflow::MicroActor
- Includes:
- Algebrick::Matching, Algebrick::TypeCheck
- Defined in:
- lib/dynflow/micro_actor.rb
Direct Known Subclasses
Clock, Executors::Parallel::Core, Executors::Parallel::Pool, Executors::Parallel::Worker, Executors::RemoteViaSocket::Core
Constant Summary collapse
- Terminate =
Algebrick.atom
Instance Attribute Summary collapse
-
#initialized ⇒ Object
readonly
Returns the value of attribute initialized.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #<<(message) ⇒ Object
- #ask(message, future = Future.new) ⇒ Object
-
#initialize(logger, *args) ⇒ MicroActor
constructor
A new instance of MicroActor.
- #stopped? ⇒ Boolean
Constructor Details
#initialize(logger, *args) ⇒ MicroActor
Returns a new instance of MicroActor.
10 11 12 13 14 15 |
# File 'lib/dynflow/micro_actor.rb', line 10 def initialize(logger, *args) @logger = logger @initialized = Future.new @thread = Thread.new { run *args } Thread.pass until @mailbox end |
Instance Attribute Details
#initialized ⇒ Object (readonly)
Returns the value of attribute initialized.
6 7 8 |
# File 'lib/dynflow/micro_actor.rb', line 6 def initialized @initialized end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/dynflow/micro_actor.rb', line 6 def logger @logger end |
Instance Method Details
#<<(message) ⇒ Object
17 18 19 20 21 |
# File 'lib/dynflow/micro_actor.rb', line 17 def <<() raise 'actor terminated' if terminated? @mailbox << [, nil] self end |
#ask(message, future = Future.new) ⇒ Object
23 24 25 26 27 |
# File 'lib/dynflow/micro_actor.rb', line 23 def ask(, future = Future.new) future.fail Dynflow::Error.new('actor terminated') if terminated? @mailbox << [, future] future end |
#stopped? ⇒ Boolean
29 30 31 |
# File 'lib/dynflow/micro_actor.rb', line 29 def stopped? @terminated.ready? end |