Class: EventMachine::PeriodicTimer
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/em/timers.rb |
Overview
Creates a periodic timer
Class Method Summary
-
.new(interval, callback = nil, &block) ⇒ PeriodicTimer
constructor
Create a new periodic timer that executes every interval seconds.
Instance Attribute Summary
-
#interval
rw
Fire the timer every interval seconds.
Instance Method Summary
Constructor Details
.new(interval, callback = nil, &block) ⇒ PeriodicTimer
Create a new periodic timer that executes every interval seconds
Instance Attribute Details
#interval (rw)
Fire the timer every interval seconds
# File 'lib/em/timers.rb', line 46
attr_accessor :interval
Instance Method Details
#cancel
Cancel the periodic timer
# File 'lib/em/timers.rb', line 41
def cancel @cancelled = true end
#fire
This method is for internal use only.
[ GitHub ]
# File 'lib/em/timers.rb', line 54
def fire unless @cancelled @code.call schedule end end
#schedule
This method is for internal use only.
[ GitHub ]
# File 'lib/em/timers.rb', line 49
def schedule EventMachine::add_timer @interval, @work end