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:
Future<V>
,AsyncResult<V>
- Direct Known Subclasses:
BalancedClientFuture
,ConservativeClientFuture
,ProgressiveClientFuture
public abstract class ClientFuture<V> extends Object implements Future<V>, AsyncResult<V>
Asynchronous Client Future class.
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
CANCELLED
protected static int
COMPLETING
protected ExecutionException
error
protected static int
FAILURE
protected static int
INCOMPLETE
protected V
result
protected static AtomicIntegerFieldUpdater<ClientFuture>
STATE_FIELD_UPDATER
protected static int
SUCCESS
protected ClientSynchronization<V>
synchronization
protected int
waiting
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClientFuture(ClientSynchronization<V> synchronization)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
cancel(boolean mayInterruptIfRunning)
void
complete(V result)
If the operation succeeds the resulting value produced is set to null and the waiting parties are signaled.void
failed(ClientException result)
If the operation fails this method is invoked with the Exception that caused the failure.abstract V
get()
abstract V
get(long timeout, TimeUnit unit)
V
getResult()
protected int
getState()
boolean
isCancelled()
boolean
isComplete()
Returns true if the AsyncResult has completed.boolean
isDone()
boolean
isFailed()
protected boolean
isNotComplete()
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.
-
-
-
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 AtomicIntegerFieldUpdater<ClientFuture> STATE_FIELD_UPDATER
-
error
protected 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)
-
isFailed
public boolean isFailed()
- Returns:
- true if the
Future
operation failed.
-
getResult
public V getResult()
- Returns:
- the resulting value of the operation upon successful completion.
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfaceFuture<V>
-
isComplete
public boolean isComplete()
Description copied from interface:AsyncResult
Returns true if the AsyncResult has completed. The task is considered complete regardless if it succeeded or failed.- Specified by:
isComplete
in interfaceAsyncResult<V>
- Returns:
- returns true if the asynchronous operation has completed.
-
isNotComplete
protected boolean isNotComplete()
-
getState
protected int getState()
- Returns:
- the current
ClientFuture
state as if this call.
-
failed
public void failed(ClientException result)
Description copied from interface:AsyncResult
If the operation fails this method is invoked with the Exception that caused the failure.- Specified by:
failed
in interfaceAsyncResult<V>
- Parameters:
result
- The error that resulted in this asynchronous operation failing.
-
complete
public void complete(V result)
Description copied from interface:AsyncResult
If the operation succeeds the resulting value produced is set to null and the waiting parties are signaled.- Specified by:
complete
in interfaceAsyncResult<V>
- Parameters:
result
- the object that completes the future.
-
get
public abstract V get() throws InterruptedException, ExecutionException
- Specified by:
get
in interfaceFuture<V>
- Throws:
InterruptedException
ExecutionException
-
get
public abstract V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
get
in interfaceFuture<V>
- Throws:
InterruptedException
ExecutionException
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.
-
-