Class: Higgs::Barrier
- Inherits:
-
Object
- Object
- Higgs::Barrier
- Defined in:
- lib/higgs/thread.rb
Constant Summary collapse
- CVS_ID =
for ident(1)
'$Id: thread.rb 841 2008-12-24 09:23:20Z toki $'
Instance Method Summary collapse
-
#initialize(count) ⇒ Barrier
constructor
A new instance of Barrier.
- #wait ⇒ Object
Constructor Details
#initialize(count) ⇒ Barrier
Returns a new instance of Barrier.
168 169 170 171 172 |
# File 'lib/higgs/thread.rb', line 168 def initialize(count) @count = count @lock = Mutex.new @cond = ConditionVariable.new end |
Instance Method Details
#wait ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/higgs/thread.rb', line 174 def wait @lock.synchronize{ if (@count > 0) then @count -= 1 if (@count > 0) then while (@count > 0) @cond.wait(@lock) end else @cond.broadcast end else raise 'not recycle' end } nil end |