Package org.xnio
Class FutureResult<T>
java.lang.Object
org.xnio.FutureResult<T>
- Type Parameters:
T- theIoFutureresult type
- All Implemented Interfaces:
Result<T>
A result with a corresponding
IoFuture instance.-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance.FutureResult(Executor executor) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCancelHandler(Cancellable cancellable) Add a cancellation handler.Get theIoFuturefor this manager.booleanAcknowledge the cancellation of this operation.booleansetException(IOException exception) Set the exception for this operation.booleanSet the result for this operation.
-
Constructor Details
-
FutureResult
Construct a new instance.- Parameters:
executor- the executor to use to execute listener notifiers.
-
FutureResult
public FutureResult()Construct a new instance. The direct executor will be used to execute handler notifiers.
-
-
Method Details
-
getIoFuture
Get theIoFuturefor this manager.- Returns:
- the
IoFuture
-
addCancelHandler
Add a cancellation handler. The argument will be cancelled whenever theIoFutureis cancelled. If theIoFutureis already cancelled when this method is called, the handler will be called directly.- Parameters:
cancellable- the cancel handler
-
setResult
Set the result for this operation. Any threads blocking on this instance will be unblocked. -
setException
Set the exception for this operation. Any threads blocking on this instance will be unblocked.- Specified by:
setExceptionin interfaceResult<T>- Parameters:
exception- the exception to set- Returns:
falseif the operation was already completed,trueotherwise
-
setCancelled
public boolean setCancelled()Acknowledge the cancellation of this operation.- Specified by:
setCancelledin interfaceResult<T>- Returns:
falseif the operation was already completed,trueotherwise
-