Semaphore — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::SemaphorePrivate

Inherits:

Object

Defined in:

lib/mongo/semaphore.rb

Overview

Instance Method Summarycollapse

Constructor Details

#initialize ⇒ Semaphore

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 Semaphore.

24 25 26 27 # File 'lib/mongo/semaphore.rb', line 24 def initialize @lock = Mutex.new @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.

37 38 39 40 41 # File 'lib/mongo/semaphore.rb', line 37 def broadcast @lock.synchronize do @cv.broadcast end 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 47 # File 'lib/mongo/semaphore.rb', line 43 def signal @lock.synchronize do @cv.signal end 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 semaphore to be signaled up to timeout seconds. If semaphore is not signaled, returns after timeout seconds.

31 32 33 34 35 # File 'lib/mongo/semaphore.rb', line 31 def wait(timeout = nil) @lock.synchronize do @cv.wait(@lock, timeout) end end