Class: ForeignActor::ReactorMailbox
- Inherits:
-
Celluloid::Mailbox
- Object
- Celluloid::Mailbox
- ForeignActor::ReactorMailbox
- Defined in:
- lib/foreign_actor/reactor_mailbox.rb
Instance Method Summary collapse
- #<<(message) ⇒ Object
-
#initialize ⇒ ReactorMailbox
constructor
A new instance of ReactorMailbox.
- #receive(timeout = nil, &block) ⇒ Object
Constructor Details
#initialize ⇒ ReactorMailbox
Returns a new instance of ReactorMailbox.
4 5 6 7 |
# File 'lib/foreign_actor/reactor_mailbox.rb', line 4 def initialize(*) super @actor = nil end |
Instance Method Details
#<<(message) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/foreign_actor/reactor_mailbox.rb', line 9 def <<() super if @actor if .is_a?(Celluloid::TerminationRequest) @actor.subject.suspend_reactor('exit') else @actor.subject.suspend_reactor() end end end |
#receive(timeout = nil, &block) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/foreign_actor/reactor_mailbox.rb', line 20 def receive(timeout = nil, &block) @actor ||= Thread.current[:celluloid_actor] if @messages.empty? @actor.subject.wakeup_reactor() end super end |