Interface RCountDownLatch

All Superinterfaces:
RCountDownLatchAsync, RObject, RObjectAsync
All Known Implementing Classes:
RedissonCountDownLatch

public interface RCountDownLatch extends RObject, RCountDownLatchAsync
Redis based implementation of CountDownLatch It has an advantage over CountDownLatch -- count can be set via trySetCount(long) method.
Author:
Nikita Koksharov
  • Method Details

    • await

      void await() throws InterruptedException
      Waits until counter reach zero.
      Throws:
      InterruptedException - if the current thread was interrupted
    • await

      boolean await(long timeout, TimeUnit unit) throws InterruptedException
      Waits until counter reach zero or up to defined timeout.
      Parameters:
      timeout - the maximum time to wait
      unit - the time unit
      Returns:
      true if the count reached zero and false if timeout reached before the count reached zero
      Throws:
      InterruptedException - if the current thread was interrupted
    • countDown

      void countDown()
      Decrements the counter of the latch. Notifies all waiting threads when count reaches zero.
    • getCount

      long getCount()
      Returns value of current count.
      Returns:
      current count
    • trySetCount

      boolean trySetCount(long count)
      Sets new count value only if previous count already has reached zero or is not set at all.
      Parameters:
      count - - number of times countDown() must be invoked before threads can pass through await()
      Returns:
      true if new count setted false if previous count has not reached zero