Package org.redisson.api
Interface RCountDownLatch
-
- All Superinterfaces:
RCountDownLatchAsync
,RObject
,RObjectAsync
- All Known Implementing Classes:
RedissonCountDownLatch
public interface RCountDownLatch extends RObject, RCountDownLatchAsync
Redis based implementation ofCountDownLatch
It has an advantage overCountDownLatch
-- count can be set viatrySetCount(long)
method.- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
await()
Waits until counter reach zero.boolean
await(long timeout, TimeUnit unit)
Waits until counter reach zero or up to definedtimeout
.void
countDown()
Decrements the counter of the latch.long
getCount()
Returns value of current count.boolean
trySetCount(long count)
Sets new count value only if previous count already has reached zero or is not set at all.-
Methods inherited from interface org.redisson.api.RCountDownLatchAsync
awaitAsync, awaitAsync, countDownAsync, getCountAsync, trySetCountAsync
-
Methods inherited from interface org.redisson.api.RObject
addListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Methods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
-
-
-
Method Detail
-
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 definedtimeout
.- Parameters:
timeout
- the maximum time to waitunit
- the time unit- Returns:
true
if the count reached zero andfalse
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 timescountDown()
must be invoked before threads can pass throughawait()
- Returns:
true
if new count settedfalse
if previous count has not reached zero
-
-