public class RedissonCountDownLatch extends Object implements RCountDownLatch
CountDownLatch
It has a advantage over CountDownLatch
--
count can be reset via trySetCount(long)
.Modifier and Type | Field and Description |
---|---|
static Long |
newCountMessage |
static Long |
zeroCountMessage |
Modifier | Constructor and Description |
---|---|
protected |
RedissonCountDownLatch(CommandAsyncExecutor commandExecutor,
String name,
UUID id) |
Modifier and Type | Method and Description |
---|---|
void |
await()
Causes the current thread to wait until the latch has counted down to
zero, unless the thread is interrupted.
|
protected boolean |
await(io.netty.util.concurrent.Future<?> future,
long timeout,
TimeUnit timeoutUnit) |
boolean |
await(long time,
TimeUnit unit)
Causes the current thread to wait until the latch has counted down to
zero, unless the thread is interrupted,
or the specified waiting time elapses.
|
void |
countDown()
Decrements the count of the latch, releasing all waiting threads if
the count reaches zero.
|
io.netty.util.concurrent.Future<Void> |
countDownAsync()
Decrements the count of the latch, releasing all waiting threads if
the count reaches zero.
|
boolean |
delete()
Deletes the object
|
io.netty.util.concurrent.Future<Boolean> |
deleteAsync()
Delete object in async mode
|
protected <V> V |
get(io.netty.util.concurrent.Future<V> future) |
long |
getCount()
Returns the current count.
|
io.netty.util.concurrent.Future<Long> |
getCountAsync()
Returns the current count.
|
String |
getName()
Returns name of object
|
boolean |
isExists()
Check object existence
|
io.netty.util.concurrent.Future<Boolean> |
isExistsAsync()
Check object existence in async mode.
|
void |
migrate(String host,
int port,
int database)
Transfer an object from source Redis instance to destination Redis instance
|
io.netty.util.concurrent.Future<Void> |
migrateAsync(String host,
int port,
int database)
Transfer an object from source Redis instance to destination Redis instance
in async mode
|
boolean |
move(int database)
Move object to another database
|
io.netty.util.concurrent.Future<Boolean> |
moveAsync(int database)
Move object to another database in async mode
|
protected <V> io.netty.util.concurrent.Promise<V> |
newPromise() |
protected <V> io.netty.util.concurrent.Future<V> |
newSucceededFuture(V result) |
void |
rename(String newName)
Rename current object key to
newName |
io.netty.util.concurrent.Future<Void> |
renameAsync(String newName)
Rename current object key to
newName
in async mode |
boolean |
renamenx(String newName)
Rename current object key to
newName
only if new key is not exists |
io.netty.util.concurrent.Future<Boolean> |
renamenxAsync(String newName)
Rename current object key to
newName
in async mode only if new key is not exists |
boolean |
trySetCount(long count)
Sets new count value only if previous count already has reached zero
or is not set at all.
|
io.netty.util.concurrent.Future<Boolean> |
trySetCountAsync(long count)
Sets new count value only if previous count already has reached zero
or is not set at all.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
delete, getName, isExists, migrate, move, rename, renamenx
isExistsAsync, migrateAsync, moveAsync, renameAsync, renamenxAsync
public static final Long zeroCountMessage
public static final Long newCountMessage
protected RedissonCountDownLatch(CommandAsyncExecutor commandExecutor, String name, UUID id)
public void await() throws InterruptedException
RCountDownLatch
If the current count is zero then this method returns immediately.
If the current count is greater than zero then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happen:
RCountDownLatch.countDown()
method; or
If the current thread:
InterruptedException
is thrown and the current thread's
interrupted status is cleared.await
in interface RCountDownLatch
InterruptedException
- if the current thread is interrupted
while waitingpublic boolean await(long time, TimeUnit unit) throws InterruptedException
RCountDownLatch
If the current count is zero then this method returns immediately
with the value true
.
If the current count is greater than zero then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happen:
RCountDownLatch.countDown()
method; or
If the count reaches zero then the method returns with the
value true
.
If the current thread:
InterruptedException
is thrown and the current thread's
interrupted status is cleared.
If the specified waiting time elapses then the value false
is returned. If the time is less than or equal to zero, the method
will not wait at all.
await
in interface RCountDownLatch
time
- the maximum time to waitunit
- the time unit of the timeout
argumenttrue
if the count reached zero and false
if the waiting time elapsed before the count reached zeroInterruptedException
- if the current thread is interrupted
while waitingpublic void countDown()
RCountDownLatch
If the current count is greater than zero then it is decremented. If the new count is zero then all waiting threads are re-enabled for thread scheduling purposes.
If the current count equals zero then nothing happens.
countDown
in interface RCountDownLatch
public io.netty.util.concurrent.Future<Void> countDownAsync()
RCountDownLatchAsync
If the current count is greater than zero then it is decremented. If the new count is zero then all waiting threads are re-enabled for thread scheduling purposes.
If the current count equals zero then nothing happens.
countDownAsync
in interface RCountDownLatchAsync
public long getCount()
RCountDownLatch
This method is typically used for debugging and testing purposes.
getCount
in interface RCountDownLatch
public io.netty.util.concurrent.Future<Long> getCountAsync()
RCountDownLatchAsync
This method is typically used for debugging and testing purposes.
getCountAsync
in interface RCountDownLatchAsync
public boolean trySetCount(long count)
RCountDownLatch
trySetCount
in interface RCountDownLatch
count
- - number of times RCountDownLatch.countDown()
must be invoked
before threads can pass through RCountDownLatch.await()
true
if new count setted
false
if previous count has not reached zeropublic io.netty.util.concurrent.Future<Boolean> trySetCountAsync(long count)
RCountDownLatchAsync
trySetCountAsync
in interface RCountDownLatchAsync
count
- - number of times #countDown
must be invoked
before threads can pass through #await
true
if new count setted
false
if previous count has not reached zeropublic io.netty.util.concurrent.Future<Boolean> deleteAsync()
RObjectAsync
deleteAsync
in interface RObjectAsync
true
if object was deleted false
if notprotected boolean await(io.netty.util.concurrent.Future<?> future, long timeout, TimeUnit timeoutUnit) throws InterruptedException
InterruptedException
protected <V> V get(io.netty.util.concurrent.Future<V> future)
protected <V> io.netty.util.concurrent.Promise<V> newPromise()
protected <V> io.netty.util.concurrent.Future<V> newSucceededFuture(V result)
public void rename(String newName)
RObject
newName
public io.netty.util.concurrent.Future<Void> renameAsync(String newName)
RObjectAsync
newName
in async moderenameAsync
in interface RObjectAsync
public void migrate(String host, int port, int database)
RObject
public io.netty.util.concurrent.Future<Void> migrateAsync(String host, int port, int database)
RObjectAsync
migrateAsync
in interface RObjectAsync
host
- - destination hostport
- - destination portdatabase
- - destination databasepublic boolean move(int database)
RObject
public io.netty.util.concurrent.Future<Boolean> moveAsync(int database)
RObjectAsync
moveAsync
in interface RObjectAsync
true
if key was moved false
if notpublic boolean renamenx(String newName)
RObject
newName
only if new key is not existspublic io.netty.util.concurrent.Future<Boolean> renamenxAsync(String newName)
RObjectAsync
newName
in async mode only if new key is not existsrenamenxAsync
in interface RObjectAsync
public boolean delete()
RObject
public boolean isExists()
RObject
public io.netty.util.concurrent.Future<Boolean> isExistsAsync()
RObjectAsync
isExistsAsync
in interface RObjectAsync
true
if object exists and false
otherwiseCopyright © 2014–2016. All rights reserved.