Class: SayWhen::Poller::CelluloidPoller

Inherits:
Object
  • Object
show all
Includes:
Celluloid, BasePoller
Defined in:
lib/say_when/poller/celluloid_poller.rb

Instance Method Summary collapse

Methods included from BasePoller

#acquire, #error_tick_length, included, #job_error, #logger, #process, #process_jobs, #processor, #release, #reset_acquired, #reset_acquired_length, #storage, #tick, #tick_length

Constructor Details

#initialize(tick = nil) ⇒ CelluloidPoller

Returns a new instance of CelluloidPoller.



13
14
15
16
# File 'lib/say_when/poller/celluloid_poller.rb', line 13

def initialize(tick = nil)
  @tick_length = tick.to_i if tick
  start
end

Instance Method Details

#startObject



18
19
20
# File 'lib/say_when/poller/celluloid_poller.rb', line 18

def start
  @tick_timer = every(tick_length) { process_jobs }
end

#stopObject



22
23
24
25
26
27
# File 'lib/say_when/poller/celluloid_poller.rb', line 22

def stop
  if @tick_timer
    @tick_timer.cancel
    @tick_timer = nil
  end
end