Class: EventMachine::Timer
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/em/timers.rb |
Overview
Creates a one-time timer
timer = EventMachine::Timer.new(5) do # this will never fire because we cancel it end timer.cancel
Class Method Summary
-
.new(interval, callback = nil, &block) ⇒ Timer
constructor
Create a new timer that fires after a given number of seconds.
Instance Method Summary
-
#cancel
Cancel the timer.
Constructor Details
.new(interval, callback = nil, &block) ⇒ Timer
Create a new timer that fires after a given number of seconds
# File 'lib/em/timers.rb', line 11
def initialize interval, callback=nil, &block @signature = EventMachine::add_timer(interval, callback || block) end
Instance Method Details
#cancel
Cancel the timer
# File 'lib/em/timers.rb', line 16
def cancel EventMachine.send :cancel_timer, @signature end