Sha256: 5b857decffb569892f5f3dc74ae724b42fd594eaf5f2ebc64eacf31bfaa8d66a
Contents?: true
Size: 399 Bytes
Versions: 6
Compression:
Stored size: 399 Bytes
Contents
# the much fabled 'latch' that tenderlove and nahi were on about class Latch def initialize(count = 1) @count = count @mutex = Monitor.new @cond = @mutex.new_cond end def release @mutex.synchronize { @count -= 1 if @count > 0 @cond.broadcast if @count.zero? } end def await @mutex.synchronize { @cond.wait_while { @count > 0 } } end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
zk-1.4.2 | spec/support/latch.rb |
zk-1.4.1 | spec/support/latch.rb |
zk-1.4.0 | spec/support/latch.rb |
zk-1.3.1 | spec/support/latch.rb |
zk-1.3.0 | spec/support/latch.rb |
zk-1.2.0 | spec/support/latch.rb |