Package org.xnio

# Class FutureResult<T>

java.lang.Object
org.xnio.FutureResult<T>

Type Parameters:
  `T` - the `IoFuture` result type

All Implemented Interfaces:
  `Result<T>`

public class FutureResult<T> extends Object implements Result<T>
A result with a corresponding `IoFuture` instance.

## Constructor Summary

Constructors
Constructor
Description
`FutureResult()`
Construct a new instance.
`FutureResult(Executor executor)`
Construct a new instance.

## Method Summary

Modifier and Type
Method
Description
`void`
`addCancelHandler(Cancellable cancellable)`
Add a cancellation handler.
`IoFuture<T>`
`getIoFuture()`
Get the `IoFuture` for this manager.
`boolean`
`setCancelled()`
Acknowledge the cancellation of this operation.
`boolean`
`setException(IOException exception)`
Set the exception for this operation.
`boolean`
`setResult(T result)`
Set the result for this operation.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FutureResult

public FutureResult(Executor executor)
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

public IoFuture<T> getIoFuture()
Get the `IoFuture` for this manager.

Returns:
  the `IoFuture`

### addCancelHandler

public void addCancelHandler(Cancellable cancellable)
Add a cancellation handler. The argument will be cancelled whenever the `IoFuture` is cancelled. If the `IoFuture` is already cancelled when this method is called, the handler will be called directly.

Parameters:
  `cancellable` - the cancel handler

### setResult

public boolean setResult(T result)
Set the result for this operation. Any threads blocking on this instance will be unblocked.

Specified by:
  `setResult` in interface `Result<T>`
Parameters:
  `result` - the result to set
Returns:
  `false` if the operation was already completed, `true` otherwise

### setException

public boolean setException(IOException exception)
Set the exception for this operation. Any threads blocking on this instance will be unblocked.

Specified by:
  `setException` in interface `Result<T>`
Parameters:
  `exception` - the exception to set
Returns:
  `false` if the operation was already completed, `true` otherwise

### setCancelled

public boolean setCancelled()
Acknowledge the cancellation of this operation.

Specified by:
  `setCancelled` in interface `Result<T>`
Returns:
  `false` if the operation was already completed, `true` otherwise