Class: Mongo::Semaphore Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/mongo/semaphore.rb |
Overview
This is a semaphore implementation essentially encapsulating the sample code at ruby-doc.org/stdlib-2.0.0/libdoc/thread/rdoc/ConditionVariable.html.
Class Method Summary
- .new ⇒ Semaphore constructor Internal use only
Instance Method Summary
- #broadcast Internal use only
- #signal Internal use only
-
#wait(timeout = nil)
Internal use only
Waits for the semaphore to be signaled up to timeout seconds.
Instance Method Details
#broadcast
[ GitHub ]# File 'lib/mongo/semaphore.rb', line 37
def broadcast @lock.synchronize do @cv.broadcast end end
#signal
[ GitHub ]# File 'lib/mongo/semaphore.rb', line 43
def signal @lock.synchronize do @cv.signal end end
#wait(timeout = nil)
Waits for the semaphore to be signaled up to timeout seconds. If semaphore is not signaled, returns after timeout seconds.
# File 'lib/mongo/semaphore.rb', line 31
def wait(timeout = nil) @lock.synchronize do @cv.wait(@lock, timeout) end end