Class: Rapns::Daemon::DeliveryQueue
- Inherits:
-
Object
- Object
- Rapns::Daemon::DeliveryQueue
- Defined in:
- lib/rapns/daemon/delivery_queue.rb
Instance Method Summary collapse
-
#initialize ⇒ DeliveryQueue
constructor
A new instance of DeliveryQueue.
- #notification_processed ⇒ Object
- #notifications_processed? ⇒ Boolean
- #pop ⇒ Object
- #push(notification) ⇒ Object
Constructor Details
#initialize ⇒ DeliveryQueue
Returns a new instance of DeliveryQueue.
4 5 6 7 8 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 4 def initialize @mutex = Mutex.new @num_notifications = 0 @queue = Queue.new end |
Instance Method Details
#notification_processed ⇒ Object
19 20 21 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 19 def notification_processed @mutex.synchronize { @num_notifications -= 1 } end |
#notifications_processed? ⇒ Boolean
23 24 25 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 23 def notifications_processed? @mutex.synchronize { @num_notifications == 0 } end |
#pop ⇒ Object
15 16 17 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 15 def pop @queue.pop end |
#push(notification) ⇒ Object
10 11 12 13 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 10 def push(notification) @mutex.synchronize { @num_notifications += 1 } @queue.push(notification) end |