Class: Actor::Scheduler::Mailbox
- Inherits:
-
Rev::AsyncWatcher
- Object
- Rev::AsyncWatcher
- Actor::Scheduler::Mailbox
- Defined in:
- lib/revactor/scheduler.rb
Overview
The Scheduler Mailbox allows messages to be safely delivered across threads. If a thread is sleeping sending it a message will wake it up.
Instance Method Summary collapse
-
#initialize ⇒ Mailbox
constructor
A new instance of Mailbox.
- #send(actor, message) ⇒ Object
Constructor Details
#initialize ⇒ Mailbox
Returns a new instance of Mailbox.
98 99 100 101 102 103 |
# File 'lib/revactor/scheduler.rb', line 98 def initialize super @queue = [] @lock = Mutex.new end |
Instance Method Details
#send(actor, message) ⇒ Object
105 106 107 108 |
# File 'lib/revactor/scheduler.rb', line 105 def send(actor, ) @lock.synchronize { @queue << T[actor, ] } signal end |