Package org.redisson
Class RedissonCountDownLatch
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonCountDownLatch
-
- All Implemented Interfaces:
RCountDownLatch,RCountDownLatchAsync,RObject,RObjectAsync
public class RedissonCountDownLatch extends RedissonObject implements RCountDownLatch
Distributed alternative to theCountDownLatchIt has a advantage overCountDownLatch-- count can be reset viatrySetCount(long).- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRedissonCountDownLatch(CommandAsyncExecutor commandExecutor, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawait()Waits until counter reach zero.booleanawait(long time, TimeUnit unit)Waits until counter reach zero or up to definedtimeout.RFuture<Void>awaitAsync()Waits until counter reach zero.RFuture<Boolean>awaitAsync(long waitTime, TimeUnit unit)Waits until counter reach zero or up to definedtimeout.voidcountDown()Decrements the counter of the latch.RFuture<Void>countDownAsync()Decrements the counter of the latch.RFuture<Boolean>deleteAsync()Delete object in async modelonggetCount()Returns value of current count.RFuture<Long>getCountAsync()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.RFuture<Boolean>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, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getRawName, getRawName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListenerAsync, removeListenersAsync, 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 Detail
-
RedissonCountDownLatch
protected RedissonCountDownLatch(CommandAsyncExecutor commandExecutor, String name)
-
-
Method Detail
-
await
public void await() throws InterruptedExceptionDescription copied from interface:RCountDownLatchWaits until counter reach zero.- Specified by:
awaitin interfaceRCountDownLatch- Throws:
InterruptedException- if the current thread was interrupted
-
awaitAsync
public RFuture<Void> awaitAsync()
Description copied from interface:RCountDownLatchAsyncWaits until counter reach zero.- Specified by:
awaitAsyncin interfaceRCountDownLatchAsync- Returns:
- void
-
await
public boolean await(long time, TimeUnit unit) throws InterruptedExceptionDescription 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
public RFuture<Boolean> awaitAsync(long waitTime, TimeUnit unit)
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
public RFuture<Void> 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
public RFuture<Long> 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
public RFuture<Boolean> trySetCountAsync(long count)
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
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsyncDelete object in async mode- Specified by:
deleteAsyncin interfaceRObjectAsync- Overrides:
deleteAsyncin classRedissonObject- Returns:
trueif object was deletedfalseif not
-
-