Class: SayWhen::Poller::ConcurrentPoller
- Inherits:
-
Object
- Object
- SayWhen::Poller::ConcurrentPoller
- Includes:
- BasePoller
- Defined in:
- lib/say_when/poller/concurrent_poller.rb
Instance Method Summary collapse
-
#initialize(tick = nil) ⇒ ConcurrentPoller
constructor
A new instance of ConcurrentPoller.
- #start ⇒ Object
- #stop ⇒ Object
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) ⇒ ConcurrentPoller
Returns a new instance of ConcurrentPoller.
10 11 12 |
# File 'lib/say_when/poller/concurrent_poller.rb', line 10 def initialize(tick = nil) @tick_length = tick.to_i if tick end |
Instance Method Details
#start ⇒ Object
14 15 16 17 18 |
# 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 ⇒ Object
20 21 22 23 24 25 |
# File 'lib/say_when/poller/concurrent_poller.rb', line 20 def stop return unless @tick_timer @tick_timer.shutdown @tick_timer = nil end |