Class: SuperPoller::Poller

Inherits:
Object
  • Object
show all
Defined in:
lib/super_poller/poller.rb

Direct Known Subclasses

NoneBlockingPoller

Instance Method Summary collapse

Constructor Details

#initialize(queue, message_handler, sleep_time = 1) ⇒ Poller

Returns a new instance of Poller.



2
3
4
# File 'lib/super_poller/poller.rb', line 2

def initialize(queue, message_handler, sleep_time = 1)
  @message_handler, @queue, @sleep_time = message_handler, queue, sleep_time
end

Instance Method Details

#pollObject



6
7
8
# File 'lib/super_poller/poller.rb', line 6

def poll
  @message_handler.call(get_message)
end

#start!Object



10
11
12
# File 'lib/super_poller/poller.rb', line 10

def start!
  poll while true
end