Class: Higgs::Latch

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeLatch

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

#startObject



116
117
118
119
120
121
122
# File 'lib/higgs/thread.rb', line 116

def start
  @lock.synchronize{
    @start = true
    @cond.broadcast
  }
  nil
end

#waitObject



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