Class: Delayer::Deferred::Chain::Await
- Defined in:
- lib/delayer/deferred/chain/await.rb
Constant Summary
Constants included from Deferredable::NodeSequence
Deferredable::NodeSequence::AWAIT, Deferredable::NodeSequence::AWAIT_C, Deferredable::NodeSequence::BURST_OUT, Deferredable::NodeSequence::CALL_CHILD, Deferredable::NodeSequence::CONNECTED, Deferredable::NodeSequence::FRESH, Deferredable::NodeSequence::GENOCIDE, Deferredable::NodeSequence::GRAFT, Deferredable::NodeSequence::GRAFT_C, Deferredable::NodeSequence::PASS, Deferredable::NodeSequence::PASS_C, Deferredable::NodeSequence::RESERVED, Deferredable::NodeSequence::RESERVED_C, Deferredable::NodeSequence::ROTTEN, Deferredable::NodeSequence::RUN, Deferredable::NodeSequence::RUN_C, Deferredable::NodeSequence::SEQUENCE_LOCK, Deferredable::NodeSequence::STOP, Deferredable::NodeSequence::WAIT
Instance Attribute Summary
Attributes included from Deferredable::Chainable
Instance Method Summary collapse
- #activate(response) ⇒ Object
- #graph_child(output:) ⇒ Object
- #graph_mynode ⇒ Object
- #graph_shape ⇒ Object
-
#initialize(worker:, deferred:) ⇒ Await
constructor
A new instance of Await.
- #node_name ⇒ Object
Methods inherited from Base
Methods included from Deferredable::Chainable
#add_awaited, #add_child, #add_child_observer, #awaited, #cancel, #enter_pass, #exit_pass, #has_awaited?, #has_child?, #next, #reserve_activate, #trap
Methods included from Deferredable::NodeSequence
#activated?, #change_sequence, #on_sequence_changed, #sequence, #spoiled?
Methods included from Deferredable::Graph
#graph, #graph_draw, #graph_save
Methods included from Deferredable::Awaitable
#+@, #enter_await, #exit_await
Constructor Details
#initialize(worker:, deferred:) ⇒ Await
Returns a new instance of Await.
6 7 8 9 10 |
# File 'lib/delayer/deferred/chain/await.rb', line 6 def initialize(worker:, deferred:) super() @worker, @awaiting_deferred = worker, deferred deferred.add_awaited(self) end |
Instance Method Details
#activate(response) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/delayer/deferred/chain/await.rb', line 12 def activate(response) change_sequence(:activate) @worker.give_response(response, @awaiting_deferred) # TODO: 即座にspoilさせてよさそう ensure change_sequence(:complete) end |
#graph_child(output:) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/delayer/deferred/chain/await.rb', line 20 def graph_child(output:) output << graph_mynode if has_child? @child.graph_child(output: output) @awaiting_deferred.graph_child(output: output) output << "#{__id__} -> #{@child.__id__}" end nil end |
#graph_mynode ⇒ Object
38 39 40 41 |
# File 'lib/delayer/deferred/chain/await.rb', line 38 def graph_mynode label = "#{node_name}\n(#{sequence.name})" "#{__id__} [shape=#{graph_shape},label=#{label.inspect}]" end |
#graph_shape ⇒ Object
34 35 36 |
# File 'lib/delayer/deferred/chain/await.rb', line 34 def graph_shape 'circle'.freeze end |
#node_name ⇒ Object
30 31 32 |
# File 'lib/delayer/deferred/chain/await.rb', line 30 def node_name "Await" end |