class Concurrent::JavaCountDownLatch

@!macro count_down_latch @!visibility private @!macro internal_implementation_note

Public Class Methods

new(count = 1) click to toggle source

@!macro count_down_latch_method_initialize

# File lib/concurrent-ruby/concurrent/atomic/java_count_down_latch.rb, line 12
def initialize(count = 1)
  Utility::NativeInteger.ensure_integer_and_bounds(count)
  Utility::NativeInteger.ensure_positive(count)
  @latch = java.util.concurrent.CountDownLatch.new(count)
end

Public Instance Methods

count() click to toggle source

@!macro count_down_latch_method_count

# File lib/concurrent-ruby/concurrent/atomic/java_count_down_latch.rb, line 38
def count
  @latch.getCount
end
count_down() click to toggle source

@!macro count_down_latch_method_count_down

# File lib/concurrent-ruby/concurrent/atomic/java_count_down_latch.rb, line 33
def count_down
  @latch.countDown
end
wait(timeout = nil) click to toggle source

@!macro count_down_latch_method_wait

# File lib/concurrent-ruby/concurrent/atomic/java_count_down_latch.rb, line 19
def wait(timeout = nil)
  result = nil
  if timeout.nil?
    Synchronization::JRuby.sleep_interruptibly { @latch.await }
    result = true
  else
    Synchronization::JRuby.sleep_interruptibly do
      result = @latch.await(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS)
    end
  end
  result
end