Sha256: 0a47f98eaa2497f6983b4e66fc49465f7dcdee923801e0651afefc8f02a561b2

Contents?: true

Size: 700 Bytes

Versions: 12

Compression:

Stored size: 700 Bytes

Contents

module Sidetiq
  module Actor
    class Clock < Sidetiq::Clock
      include Sidetiq::Actor
      include Sidekiq::ExceptionHandler

      def initialize(*args, &block)
        super

        if Sidekiq.server?
          after(0) do
            debug "Sidetiq::Clock looping ..."
            loop!
          end
        end
      end

      private

      def loop!
        after([time { tick }, 0].max) do
          loop!
        end
      rescue StandardError => e
        handle_exception(e, context: 'Sidetiq::Clock#loop!')
        raise e
      end

      def time
        start = gettime
        yield
        Sidetiq.config.resolution - (gettime.to_f - start.to_f)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sidetiq-0.7.2 lib/sidetiq/actor/clock.rb
sidetiq-0.7.1 lib/sidetiq/actor/clock.rb
sidetiq-0.7.0 lib/sidetiq/actor/clock.rb
sidetiq-0.6.3 lib/sidetiq/actor/clock.rb
sidetiq-0.6.2 lib/sidetiq/actor/clock.rb
sidetiq-0.6.1 lib/sidetiq/actor/clock.rb
sidetiq-0.6.0 lib/sidetiq/actor/clock.rb
sidetiq-0.5.0 lib/sidetiq/actor/clock.rb
sidetiq-0.4.3 lib/sidetiq/actor/clock.rb
sidetiq-0.4.2 lib/sidetiq/actor/clock.rb
sidetiq-0.4.1 lib/sidetiq/actor/clock.rb
sidetiq-0.4.0 lib/sidetiq/actor/clock.rb