|
XNIO API 2.1.0.CR2 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.xnio.AbstractIoFuture<T>
T - the type of result that this operation producespublic abstract class AbstractIoFuture<T>

An abstract base class for IoFuture objects. Used to easily produce implementations.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.jboss.xnio.IoFuture |
|---|
IoFuture.HandlingNotifier<T,A>, IoFuture.Notifier<T,A>, IoFuture.Status |
| Constructor Summary | |
|---|---|
protected |
AbstractIoFuture()
Construct a new instance. |
| Method Summary | ||
|---|---|---|
protected void |
addCancelHandler(Cancellable cancellable)
Add a cancellation handler. |
|
|
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. |
|
protected Executor |
getNotifierExecutor()
Get the executor used to run asynchronous notifiers. |
|
IoFuture.Status |
getStatus()
Get the current status. |
|
protected void |
runNotifier(Runnable runnable)
Run a notifier. |
|
protected boolean |
setCancelled()
Acknowledge the cancellation of this operation. |
|
protected boolean |
setException(IOException exception)
Set the exception for this operation. |
|
protected 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 Detail |
|---|
protected AbstractIoFuture()
| Method Detail |
|---|
public IoFuture.Status getStatus()
getStatus in interface IoFuture<T>public IoFuture.Status await()
IoFuture.Status.WAITING.
await in interface IoFuture<T>
public 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.
await in interface IoFuture<T>time - the amount of time to waittimeUnit - the time unit
IoFuture.Status.WAITING if the timeout expired
public IoFuture.Status awaitInterruptibly()
throws InterruptedException
IoFuture.Status.WAITING,
or the current thread is interrupted.
awaitInterruptibly in interface IoFuture<T>InterruptedException - if the operation is interrupted
public 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.
awaitInterruptibly in interface IoFuture<T>time - the amount of time to waittimeUnit - the time unit
IoFuture.Status.WAITING if the timeout expired
InterruptedException - if the operation is interrupted
public T get()
throws IOException,
CancellationException
get in interface IoFuture<T>IOException - if the operation failed
CancellationException - if the operation was cancelled
public T getInterruptibly()
throws IOException,
InterruptedException,
CancellationException
getInterruptibly in interface IoFuture<T>IOException - if the operation failed
InterruptedException - if the operation is interrupted
CancellationException - if the operation was cancelled
public IOException getException()
throws IllegalStateException
getException in interface IoFuture<T>IllegalStateException - if the operation did not fail
public <A> IoFuture<T> addNotifier(IoFuture.Notifier<? super T,A> notifier,
A attachment)
addNotifier in interface IoFuture<T>A - the attachment typenotifier - the notifier to be calledattachment - the attachment to pass in to the notifier
protected boolean setException(IOException exception)
exception - the exception to set
false if the operation was already completed, true otherwiseprotected boolean setResult(T result)
result - the result to set
false if the operation was already completed, true otherwiseprotected boolean setCancelled()
false if the operation was already completed, true otherwisepublic IoFuture<T> cancel()
setCancelled() method to indicate that the cancel was successful. The
default implementation calls any registered cancel handlers.
cancel in interface Cancellablecancel in interface IoFuture<T>IoFuture instanceprotected void addCancelHandler(Cancellable cancellable)
IoFuture is cancelled. If
the IoFuture is already cancelled when this method is called, the handler will be called directly.
cancellable - the cancel handlerprotected void runNotifier(Runnable runnable)
Executor retrieved via getNotifierExecutor().
runnable - protected Executor getNotifierExecutor()
|
XNIO API 2.1.0.CR2 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||