Class: CountingSemaphore
Overview
Semaphore (CountingSemaphore)
Technically a semaphore is simply an integer variable which has an execution queue associated with it.
Usage
s = Semaphore.new
# to do
History
$Id: semaphore.rb,v 1.2 2003/03/15 20:10:10 fukumoto Exp $
Instance Method Summary collapse
- #exclusive ⇒ Object (also: #synchronize)
-
#initialize(initvalue = 0) ⇒ CountingSemaphore
constructor
A new instance of CountingSemaphore.
- #signal ⇒ Object (also: #up, #v)
- #wait ⇒ Object (also: #down, #p)
Constructor Details
#initialize(initvalue = 0) ⇒ CountingSemaphore
Returns a new instance of CountingSemaphore.
22 23 24 25 |
# File 'lib/carat/semaphore.rb', line 22 def initialize(initvalue = 0) @counter = initvalue @waiting_list = [] end |
Instance Method Details
#exclusive ⇒ Object Also known as: synchronize
58 59 60 61 62 63 |
# File 'lib/carat/semaphore.rb', line 58 def exclusive wait yield ensure signal end |