It is recommended, due to the vagaries of the way generics work, that when you use IoFuture instances, you
use a wildcard to express the return type. This enables you to take advantage of covariance to retrofit
more specific types later on without breaking anything.
For example, if you have a method which returns a future InputStream, you might be tempted to declare it like
this:
IoFuture<InputStream> getFutureInputStream();
Now if you later decide that what you really need is a DataInputStream (which extends InputStream),
you're in trouble because you have written IoFuture<InputStream> everywhere, which cannot be assigned to or from
an IoFuture<DataInputStream>.
On the other hand, if you declare it like this:
IoFuture<? extends InputStream> getFutureInputStream();
Now you can change it at any time to IoFuture<? extends DataInputStream> without breaking the contract, since
it will be assignable to variables of type IoFuture<? extends InputStream>.
| Modifier and Type | Class and Description |
|---|---|
| public abstract static class | IoFuture.
the type of result that the associated future operation produces T, the attachment type A>A base notifier class that calls the designated handler method on notification. |
| public static interface | IoFuture.
the type of result that the associated future operation produces T, the attachment type A>A notifier that handles changes in the status of an |
| public static enum | IoFuture.
The current status of an asynchronous operation. |
| Modifier and Type | Method and Description |
|---|---|
| public < the attachment type A> IoFuture | Returns: this instancethe notifier to be called notifier,the attachment to pass in to the notifier attachment)Add a notifier to be called when this operation is complete. |
| public IoFuture. | |
| public IoFuture. | Returns: the new status, orStatus#WAITING if the timeout expiredthe amount of time to wait time, TimeUnit the time unit timeUnit)Wait for the operation to complete, with a timeout. |
| public IoFuture. | |
| public IoFuture. | Returns: the new status, orStatus#WAITING if the timeout expiredthe amount of time to wait time, TimeUnit the time unit timeUnit)Wait for the operation to complete, with a timeout. |
| public IoFuture | |
| public T | |
| public IOException | |
| public T | |
| public IoFuture. |
| addNotifier | back to summary |
|---|---|
| public <A> IoFuture Add a notifier to be called when this operation is complete. If the operation is already complete, the notifier is called immediately, possibly in the caller's thread. The given attachment is provided to the notifier. | |
| await | back to summary |
|---|---|
| public IoFuture. Wait for the operation to complete. This method will block until the status changes from | |
| await | back to summary |
|---|---|
| public IoFuture. Wait for the operation to complete, with a timeout. This method will block until the status changes from
| |
| awaitInterruptibly | back to summary |
|---|---|
| public IoFuture. Wait for the operation to complete. This method will block until the status changes from
| |
| awaitInterruptibly | back to summary |
|---|---|
| public IoFuture. Wait for the operation to complete, with a timeout. This method will block until the status changes from
| |
| cancel | back to summary |
|---|---|
| public IoFuture Redeclares org. Doc from org. Cancel an operation. The actual cancel may be synchronous or asynchronous.
| |
| get | back to summary |
|---|---|
| public T get() throws IOException, CancellationException Get the result of the operation. If the operation is not complete, blocks until the operation completes. If the operation fails, or has already failed at the time this method is called, the failure reason is thrown.
| |
| getException | back to summary |
|---|---|
| public IOException getException() throws IllegalStateException Get the failure reason.
| |
| getInterruptibly | back to summary |
|---|---|
| public T getInterruptibly() throws IOException, InterruptedException, CancellationException Get the result of the operation. If the operation is not complete, blocks until the operation completes. If the operation fails, or has already failed at the time this method is called, the failure reason is thrown. If the current thread is interrupted while waiting, an exception is thrown.
| |
| getStatus | back to summary |
|---|---|
| public IoFuture. Get the current status. | |
org.xnio.IoFuture.Notifier implementations.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | handleFailed(final IOException
the failure reason exception, final A the attachment attachment)Handle failure. |
| public void | notify(final IoFuture<? extends T>
the future corresponding to this operation future, A the attachment attachment)Implements org. Receive notification of the completion of an outstanding operation. |
| HandlingNotifier | back to summary |
|---|---|
| public HandlingNotifier() | |
| handleCancelled | back to summary |
|---|---|
| public void handleCancelled(final A attachment) Handle cancellation.
| |
| handleDone | back to summary |
|---|---|
| public void handleDone(final T data, final A attachment) Handle completion.
| |
| handleFailed | back to summary |
|---|---|
| public void handleFailed(final IOException exception, final A attachment) Handle failure.
| |
| notify | back to summary |
|---|---|
| public void notify(final IoFuture<? extends T> future, A attachment) Implements org. Doc from org. Receive notification of the completion of an outstanding operation.
| |
IoFuture.
| Modifier and Type | Method and Description |
|---|---|
| public void |
| notify | back to summary |
|---|---|
| public void notify(IoFuture<? extends T> ioFuture, final A attachment) Receive notification of the completion of an outstanding operation.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final IoFuture. | CANCELLED
The operation was cancelled. |
| public static final IoFuture. | DONE
The operation has completed successfully. |
| public static final IoFuture. | FAILED
The operation did not succeed. |
| public static final IoFuture. | WAITING
The operation is still in progress. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static IoFuture. | |
| public static IoFuture. |
| CANCELLED | back to summary |
|---|---|
| public static final IoFuture. The operation was cancelled. | |
| DONE | back to summary |
|---|---|
| public static final IoFuture. The operation has completed successfully. | |
| FAILED | back to summary |
|---|---|
| public static final IoFuture. The operation did not succeed. | |
| WAITING | back to summary |
|---|---|
| public static final IoFuture. The operation is still in progress. | |
| Status | back to summary |
|---|---|
| private Status() | |
| valueOf | back to summary |
|---|---|
| public static IoFuture. | |
| values | back to summary |
|---|---|
| public static IoFuture. | |