Class: Wakame::Monitor::CheckerTimer
- Inherits:
-
EventMachine::PeriodicTimer
- Object
- EventMachine::PeriodicTimer
- Wakame::Monitor::CheckerTimer
- Defined in:
- lib/wakame/monitor.rb
Instance Method Summary collapse
-
#initialize(time, &blk) ⇒ CheckerTimer
constructor
A new instance of CheckerTimer.
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
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
60 61 62 |
# File 'lib/wakame/monitor.rb', line 60 def running? !@cancelled end |
#start ⇒ Object
49 50 51 52 53 54 |
# File 'lib/wakame/monitor.rb', line 49 def start if !running? @cancelled = false schedule end end |
#stop ⇒ Object
56 57 58 |
# File 'lib/wakame/monitor.rb', line 56 def stop @cancelled = true end |