Class: Push::Daemon::DeliveryHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/push/daemon/delivery_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue, connection_pool, name) ⇒ DeliveryHandler

Returns a new instance of DeliveryHandler.



6
7
8
9
10
# File 'lib/push/daemon/delivery_handler.rb', line 6

def initialize(queue, connection_pool, name)
  @queue = queue
  @connection_pool = connection_pool
  @name = "DeliveryHandler #{name}"
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/push/daemon/delivery_handler.rb', line 4

def name
  @name
end

Instance Method Details

#startObject



12
13
14
15
16
17
18
19
# File 'lib/push/daemon/delivery_handler.rb', line 12

def start
  @thread = Thread.new do
    loop do
      break if @stop
      handle_next_notification
    end
  end
end

#stopObject



21
22
23
24
# File 'lib/push/daemon/delivery_handler.rb', line 21

def stop
  @stop = true
  @queue.wakeup(@thread)
end