Class: Rpush::Daemon::DispatcherLoop
- Inherits:
-
Object
- Object
- Rpush::Daemon::DispatcherLoop
- Includes:
- Reflectable
- Defined in:
- lib/rpush/daemon/dispatcher_loop.rb
Constant Summary collapse
- WAKEUP =
:wakeup
Instance Method Summary collapse
-
#initialize(queue, dispatcher) ⇒ DispatcherLoop
constructor
A new instance of DispatcherLoop.
- #start ⇒ Object
- #stop ⇒ Object
- #wait ⇒ Object
- #wakeup ⇒ Object
Methods included from Reflectable
Constructor Details
#initialize(queue, dispatcher) ⇒ DispatcherLoop
Returns a new instance of DispatcherLoop.
8 9 10 11 |
# File 'lib/rpush/daemon/dispatcher_loop.rb', line 8 def initialize(queue, dispatcher) @queue = queue @dispatcher = dispatcher end |
Instance Method Details
#start ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rpush/daemon/dispatcher_loop.rb', line 13 def start @thread = Thread.new do loop do dispatch break if @stop end Rpush::Daemon.store.release_connection end end |
#stop ⇒ Object
24 25 26 |
# File 'lib/rpush/daemon/dispatcher_loop.rb', line 24 def stop @stop = true end |
#wait ⇒ Object
32 33 34 35 |
# File 'lib/rpush/daemon/dispatcher_loop.rb', line 32 def wait @thread.join if @thread @dispatcher.cleanup end |
#wakeup ⇒ Object
28 29 30 |
# File 'lib/rpush/daemon/dispatcher_loop.rb', line 28 def wakeup @queue.push(WAKEUP) if @thread end |