Package org.redisson
Class RedissonCountDownLatch
java.lang.Object
org.redisson.RedissonObject
org.redisson.RedissonCountDownLatch
- All Implemented Interfaces:
RCountDownLatch
,RCountDownLatchAsync
,RObject
,RObjectAsync
Distributed alternative to the
CountDownLatch
It has a advantage over CountDownLatch
--
count can be reset via trySetCount(long)
.- Author:
- Nikita Koksharov
-
Field Summary
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
Constructor Summary
ModifierConstructorDescriptionprotected
RedissonCountDownLatch
(CommandAsyncExecutor commandExecutor, String name) -
Method Summary
Modifier and TypeMethodDescriptionvoid
await()
Waits until counter reach zero.boolean
Waits until counter reach zero or up to definedtimeout
.Waits until counter reach zero.awaitAsync
(long waitTime, TimeUnit unit) Waits until counter reach zero or up to definedtimeout
.void
Decrements the counter of the latch.Decrements the counter of the latch.Delete object in async modelong
getCount()
Returns value of current count.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.trySetCountAsync
(long count) Sets new count value only if previous count already has reached zero or is not set at all.Methods inherited from class org.redisson.RedissonObject
addListener, addListener, addListenerAsync, addListenerAsync, copy, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getRawName, getRawName, getServiceManager, getSubscribeService, isExists, isExistsAsync, map, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListener, removeListenerAsync, removeListenerAsync, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsync
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
Constructor Details
-
RedissonCountDownLatch
-
-
Method Details
-
await
Description copied from interface:RCountDownLatch
Waits until counter reach zero.- Specified by:
await
in interfaceRCountDownLatch
- Throws:
InterruptedException
- if the current thread was interrupted
-
awaitAsync
Description copied from interface:RCountDownLatchAsync
Waits until counter reach zero.- Specified by:
awaitAsync
in interfaceRCountDownLatchAsync
- Returns:
- void
-
await
Description copied from interface:RCountDownLatch
Waits until counter reach zero or up to definedtimeout
.- Specified by:
await
in interfaceRCountDownLatch
- Parameters:
time
- 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
-
awaitAsync
Description copied from interface:RCountDownLatchAsync
Waits until counter reach zero or up to definedtimeout
.- Specified by:
awaitAsync
in interfaceRCountDownLatchAsync
- Parameters:
waitTime
- the maximum time to waitunit
- the time unit- Returns:
true
if the count reached zero andfalse
if timeout reached before the count reached zero
-
countDown
public void countDown()Description copied from interface:RCountDownLatch
Decrements the counter of the latch. Notifies all waiting threads when count reaches zero.- Specified by:
countDown
in interfaceRCountDownLatch
-
countDownAsync
Description copied from interface:RCountDownLatchAsync
Decrements the counter of the latch. Notifies all waiting threads when count reaches zero.- Specified by:
countDownAsync
in interfaceRCountDownLatchAsync
- Returns:
- void
-
getCount
public long getCount()Description copied from interface:RCountDownLatch
Returns value of current count.- Specified by:
getCount
in interfaceRCountDownLatch
- Returns:
- current count
-
getCountAsync
Description copied from interface:RCountDownLatchAsync
Returns value of current count.- Specified by:
getCountAsync
in interfaceRCountDownLatchAsync
- 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 interfaceRCountDownLatch
- Parameters:
count
- - number of timesRCountDownLatch.countDown()
must be invoked before threads can pass throughRCountDownLatch.await()
- Returns:
true
if new count settedfalse
if previous count has not reached zero
-
trySetCountAsync
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 interfaceRCountDownLatchAsync
- 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
-
deleteAsync
Description copied from interface:RObjectAsync
Delete object in async mode- Specified by:
deleteAsync
in interfaceRObjectAsync
- Overrides:
deleteAsync
in classRedissonObject
- Returns:
true
if object was deletedfalse
if not
-