Class: Rapns::Daemon::DeliveryQueue

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

Instance Method Summary collapse

Constructor Details

#initializeDeliveryQueue

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_processedObject



19
20
21
# File 'lib/rapns/daemon/delivery_queue.rb', line 19

def notification_processed
  @mutex.synchronize { @num_notifications -= 1 }
end

#notifications_processed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/rapns/daemon/delivery_queue.rb', line 23

def notifications_processed?
  @mutex.synchronize { @num_notifications == 0 }
end

#popObject



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