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 TypeMethodDescriptionvoid
await()
Waits until counter reach zero.boolean
Waits until counter reach zero or up to definedtimeout
.void
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 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:
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
-