123456789_123456789_123456789_123456789_123456789_

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

Instance Method Summary

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.

[ GitHub ]

  
# File 'lib/mongo/semaphore.rb', line 31

def wait(timeout = nil)
  @lock.synchronize do
    @cv.wait(@lock, timeout)
  end
end