Method: XThread::RBMonitorMixin::RBConditionVariable#wait
- Defined in:
- lib/xthread/monitor.rb
#wait(timeout = nil) ⇒ Object
Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
If timeout is given, this method returns after timeout seconds passed, even if no other thread doesn’t signal.
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/xthread/monitor.rb', line 100 def wait(timeout = nil) @monitor.__send__(:mon_check_owner) count = @monitor.__send__(:mon_exit_for_cond) begin @cond.wait(@monitor.instance_variable_get("@mon_mutex"), timeout) return true ensure @monitor.__send__(:mon_enter_for_cond, count) end end |