Method: Concurrent::JavaCountDownLatch#wait

Defined in:
lib/concurrent/atomic/count_down_latch.rb

#wait(timeout = nil) ⇒ Boolean

Block on the latch until the counter reaches zero or until timeout is reached.

Parameters:

  • timeout (Fixnum) (defaults to: nil)

    the number of seconds to wait for the counter or nil to block indefinitely

Returns:

  • (Boolean)

    true if the count reaches zero else false on timeout



86
87
88
89
90
91
92
93
# File 'lib/concurrent/atomic/count_down_latch.rb', line 86

def wait(timeout = nil)
  if timeout.nil?
    @latch.await
    true
  else
    @latch.await(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS)
  end
end