|
JBoss Threads 2.0.0.GA-redhat-2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface AsyncFuture<T>
This interface represents the result of an asynchronous future task, which provides all the features
of Future
while also adding several additional convenience methods and the ability to add asynchronous
callbacks.
Nested Class Summary | |
---|---|
static class |
AsyncFuture.AbstractListener<T,A>
An abstract base class for an implementation of the Listener interface. |
static interface |
AsyncFuture.Listener<T,A>
A listener for an asynchronous future computation result. |
static class |
AsyncFuture.Status
The possible statuses of an AsyncFuture . |
Method Summary | ||
---|---|---|
|
addListener(AsyncFuture.Listener<? super T,A> listener,
A attachment)
Add an asynchronous listener to be called when this operation completes. |
|
void |
asyncCancel(boolean interruptionDesired)
Handle an asynchronous cancellation. |
|
AsyncFuture.Status |
await()
Wait if necessary for this operation to complete, returning the outcome. |
|
AsyncFuture.Status |
await(long timeout,
TimeUnit unit)
Wait if necessary for this operation to complete, returning the outcome, which may include AsyncFuture.Status.WAITING if
the timeout expires before the operation completes. |
|
AsyncFuture.Status |
awaitUninterruptibly()
Wait (uninterruptibly) if necessary for this operation to complete, returning the outcome. |
|
AsyncFuture.Status |
awaitUninterruptibly(long timeout,
TimeUnit unit)
Wait if necessary for this operation to complete, returning the outcome, which may include AsyncFuture.Status.WAITING if
the timeout expires before the operation completes. |
|
boolean |
cancel(boolean interruptionDesired)
Synchronously cancel a task, blocking uninterruptibly until it is known whether such cancellation was successful. |
|
AsyncFuture.Status |
getStatus()
Get (poll) the current status of the asynchronous operation. |
|
T |
getUninterruptibly()
Waits (uninterruptibly) if necessary for the computation to complete, and then retrieves the result. |
|
T |
getUninterruptibly(long timeout,
TimeUnit unit)
Waits (uninterruptibly) if necessary for at most the given time for the computation to complete, and then retrieves the result, if available. |
Methods inherited from interface java.util.concurrent.Future |
---|
get, get, isCancelled, isDone |
Method Detail |
---|
AsyncFuture.Status await() throws InterruptedException
AsyncFuture.Status.COMPLETE
, AsyncFuture.Status.CANCELLED
, or AsyncFuture.Status.FAILED
.
InterruptedException
- if execution was interrupted while waitingAsyncFuture.Status await(long timeout, TimeUnit unit) throws InterruptedException
AsyncFuture.Status.WAITING
if
the timeout expires before the operation completes.
timeout
- the maximum time to waitunit
- the time unit of the timeout argument
InterruptedException
- if execution was interrupted while waitingT getUninterruptibly() throws CancellationException, ExecutionException
CancellationException
- if the computation was cancelled
ExecutionException
- if the computation threw an exceptionT getUninterruptibly(long timeout, TimeUnit unit) throws CancellationException, ExecutionException, TimeoutException
timeout
- the maximum time to waitunit
- the time unit of the timeout argument
CancellationException
- if the computation was cancelled
ExecutionException
- if the computation threw an exception
TimeoutException
- if the wait timed outAsyncFuture.Status awaitUninterruptibly()
AsyncFuture.Status.COMPLETE
, AsyncFuture.Status.CANCELLED
, or AsyncFuture.Status.FAILED
.
AsyncFuture.Status awaitUninterruptibly(long timeout, TimeUnit unit)
AsyncFuture.Status.WAITING
if
the timeout expires before the operation completes.
timeout
- the maximum time to waitunit
- the time unit of the timeout argument
AsyncFuture.Status getStatus()
<A> void addListener(AsyncFuture.Listener<? super T,A> listener, A attachment)
A
- the attachment typelistener
- the listener to addattachment
- the attachment to pass inboolean cancel(boolean interruptionDesired)
Future.cancel(boolean)
is somewhat unclear about blocking semantics.
It is recommended to use asyncCancel(boolean)
instead.
cancel
in interface Future<T>
interruptionDesired
- if interruption is desired (if available)
true
if cancel succeeded, false
otherwisevoid asyncCancel(boolean interruptionDesired)
interruptionDesired
flag
even if it has already been called without that flag set before. Otherwise, this method is
idempotent, and thus may be called more than once without additional effect.
asyncCancel
in interface AsyncCancellable
interruptionDesired
- true
if interruption of threads is desired
|
JBoss Threads 2.0.0.GA-redhat-2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |