Class ClientFuture<V>
- java.lang.Object
-
- org.apache.qpid.protonj2.client.futures.ClientFuture<V>
-
- Type Parameters:
V- the eventual result type for this Future
- All Implemented Interfaces:
java.util.concurrent.Future<V>,AsyncResult<V>
- Direct Known Subclasses:
BalancedClientFuture,ConservativeClientFuture,ProgressiveClientFuture
public abstract class ClientFuture<V> extends java.lang.Object implements java.util.concurrent.Future<V>, AsyncResult<V>
Asynchronous Client Future class.
-
-
Field Summary
Fields Modifier and Type Field Description protected static intCANCELLEDprotected static intCOMPLETINGprotected java.util.concurrent.ExecutionExceptionerrorprotected static intFAILUREprotected static intINCOMPLETEprotected Vresultprotected static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<ClientFuture>STATE_FIELD_UPDATERprotected static intSUCCESSprotected ClientSynchronization<V>synchronizationprotected intwaiting
-
Constructor Summary
Constructors Modifier Constructor Description protectedClientFuture(ClientSynchronization<V> synchronization)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)voidcomplete(V result)If the operation succeeds the resulting value produced is set to null and the waiting parties are signaled.voidfailed(ClientException result)If the operation fails this method is invoked with the Exception that caused the failure.abstract Vget()abstract Vget(long timeout, java.util.concurrent.TimeUnit unit)VgetResult()protected intgetState()booleanisCancelled()booleanisComplete()Returns true if the AsyncResult has completed.booleanisDone()booleanisFailed()protected booleanisNotComplete()protected voidtryCancelTask()TODO - Provide hook to run on the event loop to do whatever it means to cancel this task and update the task state in a thread safe manner.
-
-
-
Field Detail
-
synchronization
protected final ClientSynchronization<V> synchronization
-
INCOMPLETE
protected static final int INCOMPLETE
- See Also:
- Constant Field Values
-
COMPLETING
protected static final int COMPLETING
- See Also:
- Constant Field Values
-
SUCCESS
protected static final int SUCCESS
- See Also:
- Constant Field Values
-
FAILURE
protected static final int FAILURE
- See Also:
- Constant Field Values
-
CANCELLED
protected static final int CANCELLED
- See Also:
- Constant Field Values
-
STATE_FIELD_UPDATER
protected static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<ClientFuture> STATE_FIELD_UPDATER
-
error
protected java.util.concurrent.ExecutionException error
-
waiting
protected int waiting
-
result
protected V result
-
-
Constructor Detail
-
ClientFuture
protected ClientFuture(ClientSynchronization<V> synchronization)
-
-
Method Detail
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancelin interfacejava.util.concurrent.Future<V>
-
isFailed
public boolean isFailed()
- Returns:
- true if the
Futureoperation failed.
-
getResult
public V getResult()
- Returns:
- the resulting value of the operation upon successful completion.
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfacejava.util.concurrent.Future<V>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfacejava.util.concurrent.Future<V>
-
isComplete
public boolean isComplete()
Description copied from interface:AsyncResultReturns true if the AsyncResult has completed. The task is considered complete regardless if it succeeded or failed.- Specified by:
isCompletein interfaceAsyncResult<V>- Returns:
- returns true if the asynchronous operation has completed.
-
isNotComplete
protected boolean isNotComplete()
-
getState
protected int getState()
- Returns:
- the current
ClientFuturestate as if this call.
-
failed
public void failed(ClientException result)
Description copied from interface:AsyncResultIf the operation fails this method is invoked with the Exception that caused the failure.- Specified by:
failedin interfaceAsyncResult<V>- Parameters:
result- The error that resulted in this asynchronous operation failing.
-
complete
public void complete(V result)
Description copied from interface:AsyncResultIf the operation succeeds the resulting value produced is set to null and the waiting parties are signaled.- Specified by:
completein interfaceAsyncResult<V>- Parameters:
result- the object that completes the future.
-
get
public abstract V get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
getin interfacejava.util.concurrent.Future<V>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
get
public abstract V get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
getin interfacejava.util.concurrent.Future<V>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
tryCancelTask
protected void tryCancelTask()
TODO - Provide hook to run on the event loop to do whatever it means to cancel this task and update the task state in a thread safe manner.
-
-