Class: EventMachine::PeriodicTimer
- Inherits:
-
Object
- Object
- EventMachine::PeriodicTimer
- Defined in:
- lib/eventmachine.rb
Instance Method Summary collapse
- #cancel ⇒ Object
- #fire ⇒ Object
-
#initialize(*args, &block) ⇒ PeriodicTimer
constructor
A new instance of PeriodicTimer.
- #schedule ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ PeriodicTimer
Returns a new instance of PeriodicTimer.
1116 1117 1118 1119 1120 |
# File 'lib/eventmachine.rb', line 1116 def initialize *args, &block @interval = args.shift @code = args.shift || block schedule end |
Instance Method Details
#cancel ⇒ Object
1128 1129 1130 |
# File 'lib/eventmachine.rb', line 1128 def cancel @cancelled = true end |
#fire ⇒ Object
1124 1125 1126 1127 |
# File 'lib/eventmachine.rb', line 1124 def fire @code.call schedule unless @cancelled end |
#schedule ⇒ Object
1121 1122 1123 |
# File 'lib/eventmachine.rb', line 1121 def schedule EventMachine::add_timer @interval, proc {self.fire} end |