class ActiveSupport::Concurrency::Latch - activesupport-4.2.4 Documentation

# class ActiveSupport::Concurrency::Latch

### Public Class Methods

new(count = 1) click to toggle source

    # File lib/active_support/concurrency/latch.rb, line 7
    def initialize(count = 1)
      @count = count
      @lock = Monitor.new
      @cv = @lock.new_cond
    end

### Public Instance Methods

await() click to toggle source

    # File lib/active_support/concurrency/latch.rb, line 20
    def await
      @lock.synchronize do
        @cv.wait_while { @count > 0 }
      end
    end

release() click to toggle source

    # File 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