Sha256: 72f1ecca531b3d1a2401a21dfadff77270ad53eb2418dfad4d996faf1a994e5f

Contents?: true

Size: 594 Bytes

Versions: 5

Compression:

Stored size: 594 Bytes

Contents

# encoding: utf-8

require 'concurrent'
require 'logger'
require 'say_when/poller/base_poller'

module SayWhen
  module Poller
    class ConcurrentPoller
      include SayWhen::Poller::BasePoller

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

      def start
        @tick_timer = Concurrent::TimerTask.new(execution_interval: tick_length) do
          process_jobs
        end.tap(&:execute)
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
say_when-2.1.1 lib/say_when/poller/concurrent_poller.rb
say_when-2.1.0 lib/say_when/poller/concurrent_poller.rb
say_when-2.0.2 lib/say_when/poller/concurrent_poller.rb
say_when-2.0.1 lib/say_when/poller/concurrent_poller.rb
say_when-2.0.0 lib/say_when/poller/concurrent_poller.rb