|
XNIO API 2.1.0.CR2 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
T - the type of result that this operation producespublic interface IoFuture<T>

The future result of an asynchronous request. Use instances of this interface to retrieve the final status of an asynchronous operation.
It is recommended, due to the vagaries of the way generics work, that when you useIoFuture 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>.
| Nested Class Summary | |
|---|---|
static class |
IoFuture.HandlingNotifier<T,A>
A base notifier class that calls the designated handler method on notification. |
static interface |
IoFuture.Notifier<T,A>
A notifier that handles changes in the status of an IoFuture. |
static class |
IoFuture.Status
The current status of an asynchronous operation. |
| Method Summary | ||
|---|---|---|
|
addNotifier(IoFuture.Notifier<? super T,A> notifier,
A attachment)
Add a notifier to be called when this operation is complete. |
|
IoFuture.Status |
await()
Wait for the operation to complete. |
|
IoFuture.Status |
await(long time,
TimeUnit timeUnit)
Wait for the operation to complete, with a timeout. |
|
IoFuture.Status |
awaitInterruptibly()
Wait for the operation to complete. |
|
IoFuture.Status |
awaitInterruptibly(long time,
TimeUnit timeUnit)
Wait for the operation to complete, with a timeout. |
|
IoFuture<T> |
cancel()
Cancel an operation. |
|
T |
get()
Get the result of the operation. |
|
IOException |
getException()
Get the failure reason. |
|
T |
getInterruptibly()
Get the result of the operation. |
|
IoFuture.Status |
getStatus()
Get the current status. |
|
| Method Detail |
|---|
IoFuture<T> cancel()
cancel in interface CancellableIoFuture.Status getStatus()
IoFuture.Status await()
IoFuture.Status.WAITING.
IoFuture.Status await(long time,
TimeUnit timeUnit)
IoFuture.Status.WAITING,
or the given time elapses. If the time elapses before the operation is complete, IoFuture.Status.WAITING is
returned.
time - the amount of time to waittimeUnit - the time unit
IoFuture.Status.WAITING if the timeout expired
IoFuture.Status awaitInterruptibly()
throws InterruptedException
IoFuture.Status.WAITING,
or the current thread is interrupted.
InterruptedException - if the operation is interrupted
IoFuture.Status awaitInterruptibly(long time,
TimeUnit timeUnit)
throws InterruptedException
IoFuture.Status.WAITING,
the given time elapses, or the current thread is interrupted. If the time elapses before the operation is complete, IoFuture.Status.WAITING is
returned.
time - the amount of time to waittimeUnit - the time unit
IoFuture.Status.WAITING if the timeout expired
InterruptedException - if the operation is interrupted
T get()
throws IOException,
CancellationException
IOException - if the operation failed
CancellationException - if the operation was cancelled
T getInterruptibly()
throws IOException,
InterruptedException,
CancellationException
IOException - if the operation failed
InterruptedException - if the operation is interrupted
CancellationException - if the operation was cancelled
IOException getException()
throws IllegalStateException
IllegalStateException - if the operation did not fail
<A> IoFuture<T> addNotifier(IoFuture.Notifier<? super T,A> notifier,
A attachment)
A - the attachment typenotifier - the notifier to be calledattachment - the attachment to pass in to the notifier
|
XNIO API 2.1.0.CR2 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||