Class: Wakame::Monitor::CheckerTimer

Inherits:
EventMachine::PeriodicTimer
  • Object
show all
Defined in:
lib/wakame/monitor.rb

Instance Method Summary collapse

Constructor Details

#initialize(time, &blk) ⇒ CheckerTimer

Returns a new instance of CheckerTimer.



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/wakame/monitor.rb', line 37

def initialize(time, &blk)
  @interval = time
  @code = proc {
    begin
      blk.call
    rescue => e
      Wakame.log.error(e)
    end
  }
  stop
end

Instance Method Details

#running?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/wakame/monitor.rb', line 60

def running?
  !@cancelled 
end

#startObject



49
50
51
52
53
54
# File 'lib/wakame/monitor.rb', line 49

def start
  if !running?
    @cancelled = false
    schedule
  end
end

#stopObject



56
57
58
# File 'lib/wakame/monitor.rb', line 56

def stop
  @cancelled = true
end