Class: MonitorMixin::ConditionVariable
Overview
FIXME: This isn't documented in Nutshell.
Since MonitorMixin.new_cond returns a ConditionVariable, and the example above calls while_wait and signal, this class should be documented.
Defined Under Namespace
Classes: Timeout
Instance Method Summary (collapse)
-
- (Object) broadcast
Wakes up all threads waiting for this lock.
-
- (Object) signal
Wakes up the first thread in line waiting for this lock.
-
- (Object) wait(timeout = nil)
Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
-
- (Object) wait_until
Calls wait repeatedly until the given block yields a truthy value.
-
- (Object) wait_while
Calls wait repeatedly while the given block yields a truthy value.
Instance Method Details
- (Object) broadcast
Wakes up all threads waiting for this lock.
136 137 138 139 |
# File 'lib/monitor.rb', line 136 def broadcast @monitor.__send__(:mon_check_owner) @cond.broadcast end |
- (Object) signal
Wakes up the first thread in line waiting for this lock.
128 129 130 131 |
# File 'lib/monitor.rb', line 128 def signal @monitor.__send__(:mon_check_owner) @cond.signal end |
- (Object) wait(timeout = nil)
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.
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/monitor.rb', line 96 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 |
- (Object) wait_until
Calls wait repeatedly until the given block yields a truthy value.
119 120 121 122 123 |
# File 'lib/monitor.rb', line 119 def wait_until until yield wait end end |
- (Object) wait_while
Calls wait repeatedly while the given block yields a truthy value.
110 111 112 113 114 |
# File 'lib/monitor.rb', line 110 def wait_while while yield wait end end |