class Concurrent::Channel::Buffer::Ticker

Private Instance Methods

do_poll() click to toggle source
# File lib/concurrent/channel/buffer/ticker.rb, line 20
def do_poll
  synchronize do
    if ns_closed?
      return Concurrent::NULL, false
    elsif (now = Concurrent.monotonic_time) >= @next_tick
      tick = Concurrent::Channel::Tick.new(@next_tick)
      @next_tick = now + @interval
      return tick, true
    else
      return nil, true
    end
  end
end
ns_initialize(interval) click to toggle source
# File lib/concurrent/channel/buffer/ticker.rb, line 14
def ns_initialize(interval)
  @interval = interval.to_f
  @next_tick = Concurrent.monotonic_time + interval
  self.capacity = 1
end