Class: Iarm::Timer
- Inherits:
-
Object
- Object
- Iarm::Timer
- Defined in:
- lib/iarm/timer.rb
Defined Under Namespace
Class Method Summary collapse
Class Method Details
.crit ⇒ Object
33 34 35 |
# File 'lib/iarm/timer.rb', line 33 def self.crit yield end |
.poke(thr) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/iarm/timer.rb', line 9 def self.poke(thr) crit do if(thr)# && thr.stop?) thr.raise(Poke.new) true else false end end end |
.wait(timeout) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/iarm/timer.rb', line 20 def self.wait(timeout) timer = create_timer(timeout) yield(true) if block_given? Thread.stop rescue Timeout return false rescue Poke return true ensure Thread.kill(timer) if(timer && timer.alive?) yield(false) if block_given? end |