Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more
Object
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.
Wakes up all threads waiting for this lock.
# File monitor.rb, line 146 def broadcast @monitor.__send__(:mon_check_owner) @cond.broadcast end
Wakes up the first thread in line waiting for this lock.
# File monitor.rb, line 138 def signal @monitor.__send__(:mon_check_owner) @cond.signal end
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.
# File monitor.rb, line 106 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
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.