Package org.redisson
Class RedissonCountDownLatch
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonCountDownLatch
-
- All Implemented Interfaces:
RCountDownLatch
,RCountDownLatchAsync
,RObject
,RObjectAsync
public class RedissonCountDownLatch extends RedissonObject implements RCountDownLatch
Distributed alternative to the It has a advantage over -- 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 protected
RedissonCountDownLatch(CommandAsyncExecutor commandExecutor, name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
await()
Waits until counter reach zero.boolean
await(long time, unit)
Waits until counter reach zero or up to definedtimeout
.>
awaitAsync()
Waits until counter reach zero.>
awaitAsync(long waitTime, unit)
Waits until counter reach zero or up to definedtimeout
.void
countDown()
Decrements the counter of the latch.>
countDownAsync()
Decrements the counter of the latch.>
deleteAsync()
Delete object in async modelong
getCount()
Returns value of current count.>
getCountAsync()
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, 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 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, name)
-
-
Method Detail
-
await
public void await() throws
Description copied from interface:RCountDownLatch
Waits until counter reach zero.- Specified by:
await
in interfaceRCountDownLatch
- Throws:
- if the current thread was interrupted
-
awaitAsync
public > awaitAsync()
Description copied from interface:RCountDownLatchAsync
Waits until counter reach zero.- Specified by:
awaitAsync
in interfaceRCountDownLatchAsync
- Returns:
- void
-
await
public boolean await(long time, unit) throws
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:
- if the current thread was interrupted
-
awaitAsync
public > awaitAsync(long waitTime, unit)
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
public > 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
public > 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
public > trySetCountAsync(long count)
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
public > 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
-
-