Class: MonitorMixin::ConditionVariable
- Inherits:
-
Object
- Object
- MonitorMixin::ConditionVariable
- Defined in:
- lib/ext_monitor.rb
Instance Method Summary collapse
-
#wait(timeout = nil) ⇒ Object
Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
Instance Method Details
#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.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ext_monitor.rb', line 15 def wait(timeout = nil) @monitor.__send__(:mon_check_owner) count = @monitor.__send__(:mon_exit_for_cond) begin @cond.wait(@monitor.instance_variable_get(:@mon_data).mutex_for_cond, timeout) return true ensure @monitor.__send__(:mon_enter_for_cond, count) end end |