Package org.redisson.api
Interface RCountDownLatch
- All Superinterfaces:
RCountDownLatchAsync,RObject,RObjectAsync
- All Known Implementing Classes:
RedissonCountDownLatch
Redis based implementation of
CountDownLatch
It has an advantage over CountDownLatch --
count can be set via trySetCount(long) method.- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionvoidawait()Waits until counter reach zero.booleanWaits until counter reach zero or up to definedtimeout.voidDecrements 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, trySetCountAsyncMethods 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, unlinkMethods 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 Details
-
await
Waits until counter reach zero.- Throws:
InterruptedException- if the current thread was interrupted
-
await
Waits 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
-