Interface AsyncFuture<T>
- All Superinterfaces:
CompletionStage<T>
,Future<T>
- All Known Subinterfaces:
AsyncPromise<T>
,RunnableScheduledFuture<V>
,ScheduledFuture<V>
- All Known Implementing Classes:
AbstractAsyncFuture
,CancelledAsyncFuture
,DefaultAsyncFuture
,DefaultAsyncFutureTask
,DefaultCollectingAsyncFuture
,FailedAsyncFuture
,SuccessAsyncFuture
A
Future
which has very netty-style semantics where AsyncFutureListener
can
be added to the future to be executed upon condition of Success or Failure has been satisfied.
See DefaultAsyncFuture
.
See also DefaultAsyncFutureTask
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddListener
(AsyncFutureListener<T> listener) Adds the specified listener to this future.addListener
(AsyncPromise<T> listener) Adds the specified future as a listener to this future.await()
Waits for this future to be completed.boolean
Waits for this future to be completed within the specified time limit.Waits for this future to be completed without interruption.boolean
awaitUninterruptibly
(long timeout, TimeUnit unit) Waits for this future to be completed within the specified time limit without interruption.static <T> AsyncPromise<T>
Obtain an instance of an AsyncFuture which is in the Cancelled state.static <T> AsyncFuture<List<T>>
collect
(List<AsyncFuture<List<T>>> futuresList, boolean cancellable) static <T> AsyncPromise<T>
deferred
(boolean cancellable) Create a new default deferred future.static <T> AsyncPromise<T>
Create a new failed future.getCause()
Returns the cause of the failed I/O operation if the I/O operation has failed.getNow()
Non-blocking variant ofFuture.get()
static AsyncFuture.Status
getStatus
(AsyncFuture<?> future) boolean
Returnstrue
if and only if the I/O operation was completed successfully.static <T> AsyncFuture<T>
of
(AsyncFuture<T> stage, boolean cancellable) static <T> AsyncFuture<T>
of
(CompletionStage<T> stage, boolean cancellable) static <T,
V extends T>
AsyncPromise<T>success
(V value) Create a new success future.Methods inherited from interface java.util.concurrent.CompletionStage
acceptEither, acceptEitherAsync, acceptEitherAsync, applyToEither, applyToEitherAsync, applyToEitherAsync, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, handle, handleAsync, handleAsync, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, whenComplete, whenCompleteAsync, whenCompleteAsync
-
Field Details
-
NULL_SUCCESS
-
-
Method Details
-
getNow
T getNow()Non-blocking variant ofFuture.get()
- Returns:
- value or
null
-
isSuccess
boolean isSuccess()Returnstrue
if and only if the I/O operation was completed successfully. -
getCause
Throwable getCause()Returns the cause of the failed I/O operation if the I/O operation has failed.- Returns:
- the cause of the failure.
null
if succeeded or this future is not completed yet.
-
addListener
Adds the specified listener to this future. The specified listener is notified when this future is done. If this future is already completed, the specified listener is notified immediately.- Returns:
this
to permit chaining of operations.
-
addListener
Adds the specified future as a listener to this future. The specified future is notified when this future is done. If this future is already completed, the specified future is notified immediately.- Parameters:
listener
-- Returns:
this
to permit chaining of operations.
-
await
Waits for this future to be completed.- Throws:
InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
Waits for this future to be completed without interruption. This method catches anInterruptedException
and discards it silently. -
await
Waits for this future to be completed within the specified time limit.- Returns:
true
if and only if the future was completed within the specified time limit- Throws:
InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedException
and discards it silently.- Returns:
true
if and only if the future was completed within the specified time limit
-
of
-
of
-
cancelled
Obtain an instance of an AsyncFuture which is in the Cancelled state.- Type Parameters:
T
- any type.- Returns:
- Cancelled future.
-
deferred
Create a new default deferred future.- Type Parameters:
T
- Type of the future.- Parameters:
cancellable
- true if cancellable.- Returns:
- new deferred async future.
-
failed
Create a new failed future. These futures are already in the Done state.- Type Parameters:
T
- Type of the future.- Parameters:
exception
- exception.- Returns:
- new failed async future.
-
success
Create a new success future. These futures are already in the Done state.- Type Parameters:
T
- Type of the value.- Parameters:
value
- value of future.- Returns:
- new success async future.
-
collect
static <T> AsyncFuture<List<T>> collect(List<AsyncFuture<List<T>>> futuresList, boolean cancellable) -
getStatus
-