Interface ListenableFuture<T>
- Type Parameters:
T
- the result type returned by this Future'sget
method
- All Superinterfaces:
Future<T>
- All Known Implementing Classes:
AsyncResult
,CompletableToListenableFutureAdapter
,ListenableFutureAdapter
,ListenableFutureTask
,MonoToListenableFutureAdapter
,SettableListenableFuture
public interface ListenableFuture<T> extends Future<T>
ExtendFuture
with the capability to accept completion callbacks. If the future has completed when the callback is added, the callback is triggered immediately.Inspired by
com.google.common.util.concurrent.ListenableFuture
.- Since:
- 4.0
- Author:
- Arjen Poutsma, Sebastien Deleuze, Juergen Hoeller
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addCallback(ListenableFutureCallback<? super T> callback)
Register the givenListenableFutureCallback
.void
addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
Java 8 lambda-friendly alternative with success and failure callbacks.default CompletableFuture<T>
completable()
Expose thisListenableFuture
as a JDKCompletableFuture
.
Method Detail
addCallback
void addCallback(ListenableFutureCallback<? super T> callback)
Register the givenListenableFutureCallback
.- Parameters:
callback
- the callback to register
addCallback
void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
Java 8 lambda-friendly alternative with success and failure callbacks.- Parameters:
successCallback
- the success callbackfailureCallback
- the failure callback- Since:
- 4.1
completable
default CompletableFuture<T> completable()
Expose thisListenableFuture
as a JDKCompletableFuture
.- Since:
- 5.0