Package org.redisson

Class RedissonCountDownLatch

    • Field Detail

      • zeroCountMessage

        public static final Long zeroCountMessage
      • newCountMessage

        public static final Long newCountMessage
    • Method Detail

      • await

        public void await()
                   throws InterruptedException
        Description copied from interface: RCountDownLatch
        Causes the current thread to wait until the latch has counted down to zero, unless the thread is interrupted.

        If the current count is zero then this method returns immediately.

        If the current count is greater than zero then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happen:

        If the current thread:

        • has its interrupted status set on entry to this method; or
        • is interrupted while waiting,
        then InterruptedException is thrown and the current thread's interrupted status is cleared.
        Specified by:
        await in interface RCountDownLatch
        Throws:
        InterruptedException - if the current thread is interrupted while waiting
      • await

        public boolean await​(long time,
                             TimeUnit unit)
                      throws InterruptedException
        Description copied from interface: RCountDownLatch
        Causes the current thread to wait until the latch has counted down to zero, unless the thread is interrupted, or the specified waiting time elapses.

        If the current count is zero then this method returns immediately with the value true.

        If the current count is greater than zero then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happen:

        If the count reaches zero then the method returns with the value true.

        If the current thread:

        • has its interrupted status set on entry to this method; or
        • is interrupted while waiting,
        then InterruptedException is thrown and the current thread's interrupted status is cleared.

        If the specified waiting time elapses then the value false is returned. If the time is less than or equal to zero, the method will not wait at all.

        Specified by:
        await in interface RCountDownLatch
        Parameters:
        time - the maximum time to wait
        unit - the time unit of the timeout argument
        Returns:
        true if the count reached zero and false if the waiting time elapsed before the count reached zero
        Throws:
        InterruptedException - if the current thread is interrupted while waiting
      • countDown

        public void countDown()
        Description copied from interface: RCountDownLatch
        Decrements the count of the latch, releasing all waiting threads if the count reaches zero.

        If the current count is greater than zero then it is decremented. If the new count is zero then all waiting threads are re-enabled for thread scheduling purposes.

        If the current count equals zero then nothing happens.

        Specified by:
        countDown in interface RCountDownLatch
      • countDownAsync

        public RFuture<Void> countDownAsync()
        Description copied from interface: RCountDownLatchAsync
        Decrements the count of the latch, releasing all waiting threads if the count reaches zero.

        If the current count is greater than zero then it is decremented. If the new count is zero then all waiting threads are re-enabled for thread scheduling purposes.

        If the current count equals zero then nothing happens.

        Specified by:
        countDownAsync in interface RCountDownLatchAsync
        Returns:
        void
      • getCount

        public long getCount()
        Description copied from interface: RCountDownLatch
        Returns the current count.

        This method is typically used for debugging and testing purposes.

        Specified by:
        getCount in interface RCountDownLatch
        Returns:
        the current count
      • trySetCount

        public boolean trySetCount​(long count)
        Description copied from interface: RCountDownLatch
        Sets new count value only if previous count already has reached zero or is not set at all.
        Specified by:
        trySetCount in interface RCountDownLatch
        Parameters:
        count - - number of times RCountDownLatch.countDown() must be invoked before threads can pass through RCountDownLatch.await()
        Returns:
        true if new count setted false if previous count has not reached zero
      • trySetCountAsync

        public RFuture<Boolean> trySetCountAsync​(long count)
        Description copied from interface: RCountDownLatchAsync
        Sets new count value only if previous count already has reached zero or is not set at all.
        Specified by:
        trySetCountAsync in interface RCountDownLatchAsync
        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