class SayWhen::Poller::ConcurrentPoller

Public Class Methods

new(tick = nil) click to toggle source
# File lib/say_when/poller/concurrent_poller.rb, line 10
def initialize(tick = nil)
  @tick_length = tick.to_i if tick
end

Public Instance Methods

start() click to toggle source
# File lib/say_when/poller/concurrent_poller.rb, line 14
def start
  @tick_timer ||= Concurrent::TimerTask.new(execution_interval: tick_length) do
    process_jobs
  end.tap(&:execute)
end
stop() click to toggle source
# File lib/say_when/poller/concurrent_poller.rb, line 20
def stop
  return unless @tick_timer

  @tick_timer.shutdown
  @tick_timer = nil
end