Class: Celluloid::Timer
- Includes:
- Comparable
- Defined in:
- lib/vendor/celluloid/lib/celluloid/timers.rb
Overview
An individual timer set to fire a given proc at a given time
Constant Summary collapse
- QUANTUM =
The timer system is guaranteed (at least by the specs) to be this precise during normal operation. Long blocking calls within actors will delay the firing of timers
0.02
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#cancel ⇒ Object
Cancel this timer.
-
#fire ⇒ Object
(also: #call)
Fire the block.
-
#initialize(timers, interval, block) ⇒ Timer
constructor
A new instance of Timer.
-
#reset ⇒ Object
Reset this timer.
Constructor Details
#initialize(timers, interval, block) ⇒ Timer
Returns a new instance of Timer.
80 81 82 83 84 85 |
# File 'lib/vendor/celluloid/lib/celluloid/timers.rb', line 80 def initialize(timers, interval, block) @timers, @interval = timers, interval @block = block reset end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
78 79 80 |
# File 'lib/vendor/celluloid/lib/celluloid/timers.rb', line 78 def interval @interval end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
78 79 80 |
# File 'lib/vendor/celluloid/lib/celluloid/timers.rb', line 78 def time @time end |
Instance Method Details
#<=>(other) ⇒ Object
87 88 89 |
# File 'lib/vendor/celluloid/lib/celluloid/timers.rb', line 87 def <=>(other) @time <=> other.time end |
#cancel ⇒ Object
Cancel this timer
92 93 94 |
# File 'lib/vendor/celluloid/lib/celluloid/timers.rb', line 92 def cancel @timers.cancel self end |
#fire ⇒ Object Also known as: call
Fire the block
104 105 106 |
# File 'lib/vendor/celluloid/lib/celluloid/timers.rb', line 104 def fire @block.call end |