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 ofCountDownLatchIt 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 voidawait()Waits until counter reach zero.booleanawait(long timeout, TimeUnit unit)Waits until counter reach zero or up to definedtimeout.voidcountDown()Decrements the counter of the latch.longgetCount()Returns value of current count.booleantrySetCount(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 InterruptedExceptionWaits until counter reach zero.- Throws:
InterruptedException- if the current thread was interrupted
-
await
boolean await(long timeout, TimeUnit unit) throws InterruptedExceptionWaits until counter reach zero or up to definedtimeout.- Parameters:
timeout- the maximum time to waitunit- the time unit- Returns:
trueif the count reached zero andfalseif 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:
trueif new count settedfalseif previous count has not reached zero
-
-