Class: Higgs::Latch
- Inherits:
-
Object
- Object
- Higgs::Latch
- 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 ⇒ Latch
constructor
A new instance of Latch.
- #start ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize ⇒ Latch
Returns a new instance of Latch.
110 111 112 113 114 |
# File 'lib/higgs/thread.rb', line 110 def initialize @lock = Mutex.new @cond = ConditionVariable.new @start = false end |
Instance Method Details
#start ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/higgs/thread.rb', line 116 def start @lock.synchronize{ @start = true @cond.broadcast } nil end |
#wait ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/higgs/thread.rb', line 124 def wait @lock.synchronize{ until (@start) @cond.wait(@lock) end } nil end |