Class: Mongo::ConditionVariable Private
- Inherits:
-
Object
- Object
- Mongo::ConditionVariable
- Extended by:
- Forwardable
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/condition_variable.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This is an implementation of a condition variable.
Instance Method Summary collapse
- #broadcast ⇒ Object private
-
#initialize(lock = Mutex.new) ⇒ ConditionVariable
constructor
private
A new instance of ConditionVariable.
- #signal ⇒ Object private
-
#wait(timeout = nil) ⇒ Object
private
Waits for the condition variable to be signaled up to timeout seconds.
Constructor Details
#initialize(lock = Mutex.new) ⇒ ConditionVariable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ConditionVariable.
25 26 27 28 |
# File 'build/ruby-driver-v2.19/lib/mongo/condition_variable.rb', line 25 def initialize(lock = Mutex.new) @lock = lock @cv = ::ConditionVariable.new end |
Instance Method Details
#broadcast ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 |
# File 'build/ruby-driver-v2.19/lib/mongo/condition_variable.rb', line 38 def broadcast raise_unless_locked! @cv.broadcast end |
#signal ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 46 |
# File 'build/ruby-driver-v2.19/lib/mongo/condition_variable.rb', line 43 def signal raise_unless_locked! @cv.signal end |
#wait(timeout = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Waits for the condition variable to be signaled up to timeout seconds. If condition variable is not signaled, returns after timeout seconds.
32 33 34 35 36 |
# File 'build/ruby-driver-v2.19/lib/mongo/condition_variable.rb', line 32 def wait(timeout = nil) raise_unless_locked! return false if timeout && timeout < 0 @cv.wait(@lock, timeout) end |