Class: Rapns::Daemon::DeliveryQueue
- Inherits:
-
Object
- Object
- Rapns::Daemon::DeliveryQueue
- Defined in:
- lib/rapns/daemon/delivery_queue.rb
Defined Under Namespace
Classes: WakeupError
Instance Method Summary collapse
-
#initialize ⇒ DeliveryQueue
constructor
A new instance of DeliveryQueue.
- #notification_processed ⇒ Object
- #notifications_processed? ⇒ Boolean
- #size ⇒ Object
- #wakeup(thread) ⇒ Object
Constructor Details
#initialize ⇒ DeliveryQueue
Returns a new instance of DeliveryQueue.
14 15 16 17 18 19 20 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 14 def initialize @num_notifications = 0 @queue = [] @waiting = [] super end |
Instance Method Details
#notification_processed ⇒ Object
33 34 35 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 33 def notification_processed synchronize { @num_notifications -= 1 } end |
#notifications_processed? ⇒ Boolean
37 38 39 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 37 def notifications_processed? synchronize { @num_notifications <= 0 } end |
#size ⇒ Object
29 30 31 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 29 def size synchronize { @queue.size } end |
#wakeup(thread) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rapns/daemon/delivery_queue.rb', line 22 def wakeup(thread) synchronize do t = @waiting.delete(thread) t.raise WakeupError if t end end |