T
- Type of object returned from this future.public class OperationFuture<T> extends SpyObject 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)
Create an OperationFuture for a given async operation.
|
OperationFuture(java.lang.String k,
java.util.concurrent.CountDownLatch l,
long opTimeout)
Create an OperationFuture for a given async operation.
|
Modifier and Type | Method and Description |
---|---|
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().
|
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.
|
protected OperationStatus status
public OperationFuture(java.lang.String k, java.util.concurrent.CountDownLatch l, long opTimeout)
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)
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.InterruptedException
java.util.concurrent.ExecutionException
public 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.InterruptedException
java.util.concurrent.TimeoutException
java.util.concurrent.ExecutionException
public 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>
Copyright © 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.