edge badge
Methods
A
N
R
Class Public methods
new(count = 1)
# File activesupport/lib/active_support/concurrency/latch.rb, line 7
def initialize(count = 1)
  @count = count
  @lock = Monitor.new
  @cv = @lock.new_cond
end
Instance Public methods
await()
# File activesupport/lib/active_support/concurrency/latch.rb, line 20
def await
  @lock.synchronize do
    @cv.wait_while { @count > 0 }
  end
end
release()
# File activesupport/lib/active_support/concurrency/latch.rb, line 13
def release
  @lock.synchronize do
    @count -= 1 if @count > 0
    @cv.broadcast if @count.zero?
  end
end