Class: Rapns::Daemon::DeliveryQueue19
- Inherits:
-
Object
- Object
- Rapns::Daemon::DeliveryQueue19
- Defined in:
- lib/rapns/daemon/delivery_queue_19.rb
Instance Method Summary collapse
-
#initialize ⇒ DeliveryQueue19
constructor
A new instance of DeliveryQueue19.
- #pop ⇒ Object
- #push(notification) ⇒ Object
Constructor Details
#initialize ⇒ DeliveryQueue19
Returns a new instance of DeliveryQueue19.
4 5 6 |
# File 'lib/rapns/daemon/delivery_queue_19.rb', line 4 def initialize @mutex = Mutex.new end |
Instance Method Details
#pop ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rapns/daemon/delivery_queue_19.rb', line 22 def pop @mutex.synchronize do while true if @queue.empty? @waiting.push Thread.current @mutex.sleep else return @queue.shift end end end end |
#push(notification) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rapns/daemon/delivery_queue_19.rb', line 8 def push(notification) @mutex.synchronize do @num_notifications += 1 @queue.push(notification) begin t = @waiting.shift t.wakeup if t rescue ThreadError retry end end end |