In Files

Parent

Methods

EventMachine::PeriodicTimer

Creates a periodic timer

n = 0
timer = EventMachine::PeriodicTimer.new(5) do
  puts "the time is #{Time.now}"
  timer.cancel if (n+=1) > 5
end

Attributes

interval[RW]

Fire the timer every interval seconds

Public Class Methods

new(interval, callback=nil, &block) click to toggle source

Create a new periodic timer that executes every interval seconds

# File lib/em/timers.rb, line 31
def initialize interval, callback=nil, &block
  @interval = interval
  @code = callback || block
  @cancelled = false
  schedule
end

Public Instance Methods

cancel() click to toggle source

Cancel the periodic timer

# File lib/em/timers.rb, line 39
def cancel
  @cancelled = true
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.