module Fluent::PluginHelper::Timer

Attributes

_timers[R]

stop : turn checker into false (callbacks not called anymore) shutdown : [-] close : [-] terminate: [-]

Public Class Methods

new() click to toggle source
Calls superclass method Fluent::PluginHelper::EventLoop::new
# File lib/fluent/plugin_helper/timer.rb, line 48
def initialize
  super
  @_timers ||= Set.new
end

Public Instance Methods

start() click to toggle source
Calls superclass method Fluent::PluginHelper::EventLoop#start
# File lib/fluent/plugin_helper/timer.rb, line 53
def start
  super
  @_timer_running = true
end
stop() click to toggle source
Calls superclass method
# File lib/fluent/plugin_helper/timer.rb, line 58
def stop
  super
  @_timer_running = false
end
terminate() click to toggle source
# File lib/fluent/plugin_helper/timer.rb, line 63
def terminate
  super
  @_timers = nil
end
timer_execute(title, interval, repeat: true, &block) click to toggle source

interval: integer/float, repeat: true/false

# File lib/fluent/plugin_helper/timer.rb, line 33
def timer_execute(title, interval, repeat: true, &block)
  raise ArgumentError, "BUG: title must be a symbol" unless title.is_a? Symbol
  raise ArgumentError, "BUG: block not specified for callback" unless block_given?
  checker = ->(){ @_timer_running }
  detacher = ->(watcher){ event_loop_detach(watcher) }
  timer = TimerWatcher.new(title, interval, repeat, log, checker, detacher, &block)
  @_timers << title
  event_loop_attach(timer)
  timer
end
timer_running?() click to toggle source
# File lib/fluent/plugin_helper/timer.rb, line 44
def timer_running?
  defined?(@_timer_running) && @_timer_running
end