public class AsyncResult<V> extends Object implements ListenableFuture<V>
Future
handle that can be used for method signatures
which are declared with a Future
return type for asynchronous execution.
As of Spring 4.1, this class implements ListenableFuture
, not just
plain Future
, along with the corresponding support
in @Async
processing.
Async
Constructor and Description |
---|
AsyncResult(V value)
Create a new AsyncResult holder.
|
Modifier and Type | Method and Description |
---|---|
void |
addCallback(ListenableFutureCallback<? super V> callback)
Registers the given callback to this
ListenableFuture . |
void |
addCallback(SuccessCallback<? super V> successCallback,
FailureCallback failureCallback)
Registers the given success and failure callbacks to this
ListenableFuture . |
boolean |
cancel(boolean mayInterruptIfRunning) |
V |
get() |
V |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
public AsyncResult(V value)
value
- the value to pass throughpublic boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled
in interface Future<V>
public void addCallback(ListenableFutureCallback<? super V> callback)
ListenableFuture
ListenableFuture
. The callback will
be triggered when this Future
is complete or, if it is already complete,
immediately.addCallback
in interface ListenableFuture<V>
callback
- the callback to registerpublic void addCallback(SuccessCallback<? super V> successCallback, FailureCallback failureCallback)
ListenableFuture
ListenableFuture
.
The callback will be triggered when this Future
is complete or, if it is
already complete immediately. This is a Java 8 lambdas compliant alternative to
ListenableFuture.addCallback(ListenableFutureCallback)
.addCallback
in interface ListenableFuture<V>
successCallback
- the success callback to registerfailureCallback
- the failure callback to register