T - Type of object returned from this future.public class OperationFuture<T> extends AbstractListenableFuture<T,OperationCompletionListener> implements java.util.concurrent.Future<T>
From an OperationFuture, application code can determine if the status of a given Operation in an asynchronous manner.
If for example we needed to update the keys "user:
| Modifier and Type | Field and Description |
|---|---|
protected OperationStatus |
status |
| Constructor and Description |
|---|
OperationFuture(java.lang.String k,
java.util.concurrent.CountDownLatch l,
java.util.concurrent.atomic.AtomicReference<T> oref,
long opTimeout,
java.util.concurrent.ExecutorService service)
Create an OperationFuture for a given async operation.
|
OperationFuture(java.lang.String k,
java.util.concurrent.CountDownLatch l,
long opTimeout,
java.util.concurrent.ExecutorService service)
Create an OperationFuture for a given async operation.
|
| Modifier and Type | Method and Description |
|---|---|
OperationFuture<T> |
addListener(OperationCompletionListener listener)
Add a listener to the future, which will be executed once the operation
completes.
|
boolean |
cancel()
Cancel this operation, if possible.
|
boolean |
cancel(boolean ign)
Deprecated.
|
T |
get()
Get the results of the given operation.
|
T |
get(long duration,
java.util.concurrent.TimeUnit units)
Get the results of the given operation.
|
java.lang.Long |
getCas()
Get the CAS for this operation.
|
java.lang.String |
getKey()
Get the key for this operation.
|
OperationStatus |
getStatus()
Get the current status of this operation.
|
boolean |
isCancelled()
Whether or not the Operation associated with this OperationFuture has been
canceled.
|
boolean |
isDone()
Whether or not the Operation is done and result can be retrieved with
get().
|
OperationFuture<T> |
removeListener(OperationCompletionListener listener)
Remove a previously added listener from the future.
|
void |
set(T o,
OperationStatus s)
Set the Operation associated with this OperationFuture.
|
void |
setCas(long inCas)
Set the key for this operation.
|
void |
setOperation(Operation to)
Set the Operation associated with this OperationFuture.
|
void |
signalComplete()
Signals that this future is complete.
|
addToListeners, executor, notifyListener, notifyListeners, notifyListeners, removeFromListenersprotected OperationStatus status
public OperationFuture(java.lang.String k,
java.util.concurrent.CountDownLatch l,
long opTimeout,
java.util.concurrent.ExecutorService service)
k - the key for the operationl - the latch to be used counting down the OperationFutureopTimeout - the timeout within which the operation needs to be donepublic OperationFuture(java.lang.String k,
java.util.concurrent.CountDownLatch l,
java.util.concurrent.atomic.AtomicReference<T> oref,
long opTimeout,
java.util.concurrent.ExecutorService service)
k - the key for the operationl - the latch to be used counting down the OperationFutureoref - an AtomicReference associated with the operationopTimeout - the timeout within which the operation needs to be donepublic boolean cancel(boolean ign)
cancel in interface java.util.concurrent.Future<T>ign - not usedpublic boolean cancel()
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<T>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic T get(long duration, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<T>duration - amount of time to waitunits - unit of time to waitjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutExceptionjava.util.concurrent.ExecutionExceptionpublic java.lang.String getKey()
public void setCas(long inCas)
inCas - the CAS valuepublic java.lang.Long getCas()
java.lang.UnsupportedOperationException - If this is for an ASCII protocol
configured client.public OperationStatus getStatus()
public void set(T o, OperationStatus s)
o - the Operation object itselfs - the OperationStatus associated with this operationpublic void setOperation(Operation to)
to - the Operation to set this OperationFuture to be trackingpublic boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<T>public boolean isDone()
isDone in interface java.util.concurrent.Future<T>public OperationFuture<T> addListener(OperationCompletionListener listener)
ListenableFutureaddListener in interface ListenableFuture<T,OperationCompletionListener>listener - the listener which will be executed.public OperationFuture<T> removeListener(OperationCompletionListener listener)
ListenableFutureremoveListener in interface ListenableFuture<T,OperationCompletionListener>listener - the previously added listener.public void signalComplete()
Copyright © 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.