wait(timeout = nil)
public
Create a new
timer with the argument timeout, and add the current thread to the list of
waiters. Then the thread is stopped. It will be resumed when a
corresponding #signal occurs.
Show source
def wait(timeout = nil)
@monitor.instance_eval {mon_check_owner()}
timer = create_timer(timeout)
Thread.critical = true
count = @monitor.instance_eval {mon_exit_for_cond()}
@waiters.push(Thread.current)
begin
Thread.stop
return true
rescue Timeout
return false
ensure
Thread.critical = true
begin
if timer && timer.alive?
Thread.kill(timer)
end
if @waiters.include?(Thread.current)
@waiters.delete(Thread.current)
end
@monitor.instance_eval {mon_enter_for_cond(count)}
ensure
Thread.critical = false
end
end
end