public class RedissonCountDownLatch extends Object implements RCountDownLatch
CountDownLatch
It has a advantage over CountDownLatch
--
count can be reset via trySetCount(long)
.Modifier | Constructor and Description |
---|---|
protected |
RedissonCountDownLatch(CommandExecutor 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.
|
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.
|
boolean |
delete()
Deletes the object
|
io.netty.util.concurrent.Future<Boolean> |
deleteAsync() |
protected <V> V |
get(io.netty.util.concurrent.Future<V> future) |
long |
getCount()
Returns the current count.
|
String |
getName()
Returns name of object
|
void |
migrate(String host,
int port,
int database)
Transfer a object from a source Redis instance to a destination Redis instance
|
io.netty.util.concurrent.Future<Void> |
migrateAsync(String host,
int port,
int database)
Transfer a object from a source Redis instance to a 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 not been setted at all.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
delete, getName, migrate, move, rename, renamenx
migrateAsync, moveAsync, renameAsync, renamenxAsync
protected RedissonCountDownLatch(CommandExecutor 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 long getCount()
RCountDownLatch
This method is typically used for debugging and testing purposes.
getCount
in interface RCountDownLatch
public boolean trySetCount(long count)
RCountDownLatch
trySetCount
in interface RCountDownLatch
count
- the 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> deleteAsync()
deleteAsync
in interface RObjectAsync
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 else false
public 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
Copyright © 2014–2015. All rights reserved.