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
ConstructorsModifierConstructorDescriptionprotectedRedissonCountDownLatch(CommandAsyncExecutor commandExecutor, String name) -
Method Summary
Modifier and TypeMethodDescriptionvoidawait()Waits until counter reach zero.booleanWaits 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.voidDecrements the counter of the latch.Decrements the counter of the latch.Delete object in async modelonggetCount()Returns value of current count.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.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, addListener, addListenerAsync, addListenerAsync, addListenerAsync, addListenerId, addTrackingListener, addTrackingListenerAsync, checkNotBatch, copy, copy, copy, copyAndReplace, copyAndReplace, copyAndReplaceAsync, copyAndReplaceAsync, copyAsync, copyAsync, copyAsync, copyAsync, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getListenerIdsByName, getLockByMapKey, getLockByValue, getName, getNameByListenerId, getRawName, getRawName, getServiceManager, getSubscribeService, isExists, isExistsAsync, map, mapName, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListener, removeListenerAsync, removeListenerAsync, removeListenerAsync, removeListenerId, removeListeners, removeTrackingListener, removeTrackingListenerAsync, rename, renameAsync, renameAsync, renameAsync, renamenx, renamenxAsync, renamenxAsync, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.redisson.api.RObject
addListener, copy, copy, copy, copyAndReplace, copyAndReplace, 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, copyAndReplaceAsync, copyAndReplaceAsync, copyAsync, copyAsync, 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:RCountDownLatchWaits until counter reach zero.- Specified by:
awaitin interfaceRCountDownLatch- Throws:
InterruptedException- if the current thread was interrupted
-
awaitAsync
Description copied from interface:RCountDownLatchAsyncWaits until counter reach zero.- Specified by:
awaitAsyncin interfaceRCountDownLatchAsync- Returns:
- void
-
await
Description copied from interface:RCountDownLatchWaits until counter reach zero or up to definedtimeout.- Specified by:
awaitin interfaceRCountDownLatch- Parameters:
time- 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
-
awaitAsync
Description copied from interface:RCountDownLatchAsyncWaits until counter reach zero or up to definedtimeout.- Specified by:
awaitAsyncin interfaceRCountDownLatchAsync- Parameters:
waitTime- the maximum time to waitunit- the time unit- Returns:
trueif the count reached zero andfalseif timeout reached before the count reached zero
-
countDown
public void countDown()Description copied from interface:RCountDownLatchDecrements the counter of the latch. Notifies all waiting threads when count reaches zero.- Specified by:
countDownin interfaceRCountDownLatch
-
countDownAsync
Description copied from interface:RCountDownLatchAsyncDecrements the counter of the latch. Notifies all waiting threads when count reaches zero.- Specified by:
countDownAsyncin interfaceRCountDownLatchAsync- Returns:
- void
-
getCount
public long getCount()Description copied from interface:RCountDownLatchReturns value of current count.- Specified by:
getCountin interfaceRCountDownLatch- Returns:
- current count
-
getCountAsync
Description copied from interface:RCountDownLatchAsyncReturns value of current count.- Specified by:
getCountAsyncin interfaceRCountDownLatchAsync- Returns:
- the current count
-
trySetCount
public boolean trySetCount(long count) Description copied from interface:RCountDownLatchSets new count value only if previous count already has reached zero or is not set at all.- Specified by:
trySetCountin interfaceRCountDownLatch- Parameters:
count- - number of timesRCountDownLatch.countDown()must be invoked before threads can pass throughRCountDownLatch.await()- Returns:
trueif new count settedfalseif previous count has not reached zero
-
trySetCountAsync
Description copied from interface:RCountDownLatchAsyncSets new count value only if previous count already has reached zero or is not set at all.- Specified by:
trySetCountAsyncin interfaceRCountDownLatchAsync- Parameters:
count- - number of timescountDownmust be invoked before threads can pass throughawait- Returns:
trueif new count settedfalseif previous count has not reached zero
-
deleteAsync
Description copied from interface:RObjectAsyncDelete object in async mode- Specified by:
deleteAsyncin interfaceRObjectAsync- Overrides:
deleteAsyncin classRedissonObject- Returns:
trueif object was deletedfalseif not
-