Method: Hopper#start
- Defined in:
- lib/hopper.rb
#start ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/hopper.rb', line 23 def start @running = true @thread = Thread.new do while @running timed_out = false # wait for signal or timeout @signal_mutex.synchronize { if @condvar.wait(@signal_mutex, @timeout) then timed_out = false else timed_out = true end } # yield passed block @hopper_mutex.synchronize { if @always || @hopper.size > 0 @block.call @hopper, timed_out if @block end @hopper = Array.new @condvar.signal if @exact } end end end |