Class: Daemon::Supervision::Timers
- Inherits:
-
Object
- Object
- Daemon::Supervision::Timers
- Includes:
- Enumerable
- Defined in:
- lib/onapp/engine/supervision/timers.rb
Instance Method Summary (collapse)
- - (Object) cancel_timer(name)
- - (Object) clear_timers
- - (Object) each(&block)
-
- (Timers) initialize
constructor
A new instance of Timers.
- - (Object) set_timer(name, interval, &block)
Constructor Details
- (Timers) initialize
Returns a new instance of Timers
9 10 11 |
# File 'lib/onapp/engine/supervision/timers.rb', line 9 def initialize extend(MonitorMixin) end |
Instance Method Details
- (Object) cancel_timer(name)
25 26 27 28 29 30 31 |
# File 'lib/onapp/engine/supervision/timers.rb', line 25 def cancel_timer(name) synchronize do name = name.to_s timer = timers.delete(name) timer.cancel if timer end end |
- (Object) clear_timers
33 34 35 36 37 38 39 |
# File 'lib/onapp/engine/supervision/timers.rb', line 33 def clear_timers synchronize do timers.dup.each do |name, timer| cancel_timer(name) end end end |
- (Object) each(&block)
13 14 15 |
# File 'lib/onapp/engine/supervision/timers.rb', line 13 def each(&block) timers.each(&block) end |
- (Object) set_timer(name, interval, &block)
17 18 19 20 21 22 23 |
# File 'lib/onapp/engine/supervision/timers.rb', line 17 def set_timer(name, interval, &block) synchronize do name = name.to_s cancel_timer(name) timers[name] = em_add_timer(interval, &block) end end |