Class: Plumbing::Actor::Message
- Includes:
- Plumbing::Awaitable
- Defined in:
- lib/plumbing/actor/message.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#_wait_until_ready ⇒ Object
38 39 40 |
# File 'lib/plumbing/actor/message.rb', line 38 def _wait_until_ready raise NotImplementedError end |
#await ⇒ Object
33 34 35 36 |
# File 'lib/plumbing/actor/message.rb', line 33 def await _wait_until_ready @exception.nil? ? @result : raise(@exception) end |
#deliver ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/plumbing/actor/message.rb', line 18 def deliver stack = (Fiber[Plumbing::Actor::FIBER_KEY] ||= []) stack.push(@sender) @result = @actor.send(@implementation, **@params, &@block) @status = :done rescue => ex @exception = ex @status = :error ensure stack.pop # Keep the "nil at the top level" invariant: once the outermost message # unwinds, clear the fiber-local rather than leaving an empty array. Fiber[Plumbing::Actor::FIBER_KEY] = nil if stack.empty? end |