public interface ListenableFuture<T> extends Future<T>
Future
interface with the capability to accept completion
callbacks. If the future has already completed when the callback is added, the
callback will be triggered immediately.
Inspired by com.google.common.util.concurrent.ListenableFuture
.
Modifier and Type | Method and Description |
---|---|
void |
addCallback(ListenableFutureCallback<? super T> callback)
Registers the given callback to this
ListenableFuture . |
void |
addCallback(SuccessCallback<? super T> successCallback,
FailureCallback failureCallback)
Registers the given success and failure callbacks to this
ListenableFuture . |
void addCallback(ListenableFutureCallback<? super T> callback)
ListenableFuture
. The callback will
be triggered when this Future
is complete or, if it is already complete,
immediately.callback
- the callback to registervoid addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
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
addCallback(ListenableFutureCallback)
.successCallback
- the success callback to registerfailureCallback
- the failure callback to register