Class: Rapns::Daemon::DeliveryQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/rapns/daemon/delivery_queue.rb

Defined Under Namespace

Classes: WakeupError

Instance Method Summary collapse

Constructor Details

#initializeDeliveryQueue

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_processedObject



33
34
35
# File 'lib/rapns/daemon/delivery_queue.rb', line 33

def notification_processed
  synchronize { @num_notifications -= 1 }
end

#notifications_processed?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rapns/daemon/delivery_queue.rb', line 37

def notifications_processed?
  synchronize { @num_notifications <= 0 }
end

#sizeObject



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