Top Description Methods
io.netty5.util.concurrent

public Interface FutureCompletionStage<V>

extends CompletionStage<V>, Future<V>, AsynchronousResult<V>
Known Direct Implementers
io.netty5.util.concurrent.DefaultPromise
Type Parameters
<V>
the value type.
Imports
io.netty5.util.internal.StringUtil, java.util.Objects, java.util.concurrent.CancellationException, .CompletableFuture, .CompletionException, .CompletionStage, .Executor, .TimeUnit, java.util.function.BiConsumer, .BiFunction, .Consumer, .Function

A CompletionStage that provides the same threading semantics and guarantees as the underlying Future, which means that all the callbacks will be executed by executor() if not specified otherwise (by calling the corresponding *Async methods).

This interface also extends java.util.concurrent.Future, to provide blocking methods for awaiting the result of the future. This is in contrast to the Netty Future, which is entirely non-blocking.

Please be aware that FutureCompletionStage#toCompletableFuture() is not supported and so will throw an UnsupportedOperationException when invoked.

Method Summary

Modifier and TypeMethod and Description
public FutureCompletionStage<Void>
acceptEither(CompletionStage<? extends V>
the other CompletionStage
other
,
Consumer<? super V>
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.acceptEither.

Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed with the corresponding result as argument to the supplied action.
public FutureCompletionStage<Void>
acceptEitherAsync(CompletionStage<? extends V>
the other CompletionStage
other
,
Consumer<? super V>
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.acceptEitherAsync.

Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed using this stage's default asynchronous execution facility, with the corresponding result as argument to the supplied action.
public FutureCompletionStage<Void>
acceptEitherAsync(CompletionStage<? extends V>
the other CompletionStage
other
,
Consumer<? super V>
the action to perform before completing the returned CompletionStage
action
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.acceptEitherAsync.

Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed using the supplied executor, with the corresponding result as argument to the supplied action.
public <U> FutureCompletionStage<U>
applyToEither(CompletionStage<? extends V>
the other CompletionStage
other
,
Function<? super V, U>
the function to use to compute the value of the returned CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.applyToEither.

Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed with the corresponding result as argument to the supplied function.
public <U> FutureCompletionStage<U>
applyToEitherAsync(CompletionStage<? extends V>
the other CompletionStage
other
,
Function<? super V, U>
the function to use to compute the value of the returned CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.applyToEitherAsync.

Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed using this stage's default asynchronous execution facility, with the corresponding result as argument to the supplied function.
public <U> FutureCompletionStage<U>
applyToEitherAsync(CompletionStage<? extends V>
the other CompletionStage
other
,
Function<? super V, U>
the function to use to compute the value of the returned CompletionStage
fn
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.applyToEitherAsync.

Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed using the supplied executor, with the corresponding result as argument to the supplied function.
public FutureCompletionStage<V>
await()

Waits for this future to be completed.

public boolean

Returns:

true if and only if the future was completed within the specified time limit
await
(long timeout, TimeUnit unit)

Waits for this future to be completed within the specified time limit.

public default boolean
cancel()

Implements io.netty5.util.concurrent.AsynchronousResult.cancel.

Cancel this asynchronous operation, unless it has already been completed or is not cancellable.
public default Throwable
cause()

Implements io.netty5.util.concurrent.AsynchronousResult.cause.

Returns the cause of the failed operation if the operation has failed.
public FutureCompletionStage<V>
exceptionally(Function<Throwable, ? extends V>
the function to use to compute the value of the returned CompletionStage if this CompletionStage completed exceptionally
fn
)

Redeclares java.util.concurrent.CompletionStage.exceptionally.

Returns a new CompletionStage that, when this stage completes exceptionally, is executed with this stage's exception as the argument to the supplied function.
public default EventExecutor
public Future<V>
future()

Returns the underlying Future of this FutureCompletionStage.

public default Throwable

Returns:

The exception that caused the future to fail, if any, or null.
getCause
()

Wait for the future to complete, and return the cause if it failed, or null if it succeeded.

public default V
getNow()

Implements io.netty5.util.concurrent.AsynchronousResult.getNow.

Return the successful result of this asynchronous operation, if any.
public <U> FutureCompletionStage<U>
handle(BiFunction<? super V, Throwable, ? extends U>
the function to use to compute the value of the returned CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.handle.

Returns a new CompletionStage that, when this stage completes either normally or exceptionally, is executed with this stage's result and exception as arguments to the supplied function.
public <U> FutureCompletionStage<U>
handleAsync(BiFunction<? super V, Throwable, ? extends U>
the function to use to compute the value of the returned CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.handleAsync.

Returns a new CompletionStage that, when this stage completes either normally or exceptionally, is executed using this stage's default asynchronous execution facility, with this stage's result and exception as arguments to the supplied function.
public <U> FutureCompletionStage<U>
handleAsync(BiFunction<? super V, Throwable, ? extends U>
the function to use to compute the value of the returned CompletionStage
fn
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.handleAsync.

Returns a new CompletionStage that, when this stage completes either normally or exceptionally, is executed using the supplied executor, with this stage's result and exception as arguments to the supplied function.
public default boolean
isCancellable()

Implements io.netty5.util.concurrent.AsynchronousResult.isCancellable.

Returns true if and only if the operation can be cancelled via cancel().
public default boolean
isFailed()

Implements io.netty5.util.concurrent.AsynchronousResult.isFailed.

Returns true if and only if the operation was completed and failed.
public default boolean
isSuccess()

Implements io.netty5.util.concurrent.AsynchronousResult.isSuccess.

Returns true if and only if the operation was completed successfully.
public default <
The return type of the resultHandler.
T
>
T

Returns:

The result of the resultHandler computation.
join
(BiFunction<V, Throwable, T>
The function that will process the result of the completed future.
resultHandler
)

Waits for the future to complete, then calls the given result handler with the outcome.

public FutureCompletionStage<Void>
runAfterBoth(CompletionStage<?>
the other CompletionStage
other
,
Runnable
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.runAfterBoth.

Returns a new CompletionStage that, when this and the other given stage both complete normally, executes the given action.
public FutureCompletionStage<Void>
runAfterBothAsync(CompletionStage<?>
the other CompletionStage
other
,
Runnable
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.runAfterBothAsync.

Returns a new CompletionStage that, when this and the other given stage both complete normally, executes the given action using this stage's default asynchronous execution facility.
public FutureCompletionStage<Void>
runAfterBothAsync(CompletionStage<?>
the other CompletionStage
other
,
Runnable
the action to perform before completing the returned CompletionStage
action
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.runAfterBothAsync.

Returns a new CompletionStage that, when this and the other given stage both complete normally, executes the given action using the supplied executor.
public FutureCompletionStage<Void>
runAfterEither(CompletionStage<?>
the other CompletionStage
other
,
Runnable
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.runAfterEither.

Returns a new CompletionStage that, when either this or the other given stage complete normally, executes the given action.
public FutureCompletionStage<Void>
runAfterEitherAsync(CompletionStage<?>
the other CompletionStage
other
,
Runnable
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.runAfterEitherAsync.

Returns a new CompletionStage that, when either this or the other given stage complete normally, executes the given action using this stage's default asynchronous execution facility.
public FutureCompletionStage<Void>
runAfterEitherAsync(CompletionStage<?>
the other CompletionStage
other
,
Runnable
the action to perform before completing the returned CompletionStage
action
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.runAfterEitherAsync.

Returns a new CompletionStage that, when either this or the other given stage complete normally, executes the given action using the supplied executor.
public FutureCompletionStage<V>
sync()

Waits for this future until it is done, and rethrows the cause of the failure if this future failed.

public FutureCompletionStage<Void>
thenAccept(Consumer<? super V>
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.thenAccept.

Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied action.
public FutureCompletionStage<Void>
thenAcceptAsync(Consumer<? super V>
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.thenAcceptAsync.

Returns a new CompletionStage that, when this stage completes normally, is executed using this stage's default asynchronous execution facility, with this stage's result as the argument to the supplied action.
public FutureCompletionStage<Void>
thenAcceptAsync(Consumer<? super V>
the action to perform before completing the returned CompletionStage
action
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.thenAcceptAsync.

Returns a new CompletionStage that, when this stage completes normally, is executed using the supplied Executor, with this stage's result as the argument to the supplied action.
public <U> FutureCompletionStage<Void>
thenAcceptBoth(CompletionStage<? extends U>
the other CompletionStage
other
,
BiConsumer<? super V, ? super U>
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.thenAcceptBoth.

Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed with the two results as arguments to the supplied action.
public <U> FutureCompletionStage<Void>
thenAcceptBothAsync(CompletionStage<? extends U>
the other CompletionStage
other
,
BiConsumer<? super V, ? super U>
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.thenAcceptBothAsync.

Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using this stage's default asynchronous execution facility, with the two results as arguments to the supplied action.
public <U> FutureCompletionStage<Void>
thenAcceptBothAsync(CompletionStage<? extends U>
the other CompletionStage
other
,
BiConsumer<? super V, ? super U>
the action to perform before completing the returned CompletionStage
action
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.thenAcceptBothAsync.

Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied action.
public <U> FutureCompletionStage<U>
thenApply(Function<? super V, ? extends U>
the function to use to compute the value of the returned CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.thenApply.

Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied function.
public <U> FutureCompletionStage<U>
thenApplyAsync(Function<? super V, ? extends U>
the function to use to compute the value of the returned CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.thenApplyAsync.

Returns a new CompletionStage that, when this stage completes normally, is executed using this stage's default asynchronous execution facility, with this stage's result as the argument to the supplied function.
public <U> FutureCompletionStage<U>
thenApplyAsync(Function<? super V, ? extends U>
the function to use to compute the value of the returned CompletionStage
fn
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.thenApplyAsync.

Returns a new CompletionStage that, when this stage completes normally, is executed using the supplied Executor, with this stage's result as the argument to the supplied function.
public <U, V1> FutureCompletionStage<V1>
thenCombine(CompletionStage<? extends U>
the other CompletionStage
other
,
BiFunction<? super V, ? super U, ? extends V1>
the function to use to compute the value of the returned CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.thenCombine.

Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed with the two results as arguments to the supplied function.
public <U, V1> FutureCompletionStage<V1>
thenCombineAsync(CompletionStage<? extends U>
the other CompletionStage
other
,
BiFunction<? super V, ? super U, ? extends V1>
the function to use to compute the value of the returned CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.thenCombineAsync.

Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using this stage's default asynchronous execution facility, with the two results as arguments to the supplied function.
public <U, V1> FutureCompletionStage<V1>
thenCombineAsync(CompletionStage<? extends U>
the other CompletionStage
other
,
BiFunction<? super V, ? super U, ? extends V1>
the function to use to compute the value of the returned CompletionStage
fn
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.thenCombineAsync.

Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied function.
public <U> FutureCompletionStage<U>
thenCompose(Function<? super V, ? extends CompletionStage<U>>
the function to use to compute another CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.thenCompose.

Returns a new CompletionStage that is completed with the same value as the CompletionStage returned by the given function.
public <U> FutureCompletionStage<U>
thenComposeAsync(Function<? super V, ? extends CompletionStage<U>>
the function to use to compute another CompletionStage
fn
)

Redeclares java.util.concurrent.CompletionStage.thenComposeAsync.

Returns a new CompletionStage that is completed with the same value as the CompletionStage returned by the given function, executed using this stage's default asynchronous execution facility.
public <U> FutureCompletionStage<U>
thenComposeAsync(Function<? super V, ? extends CompletionStage<U>>
the function to use to compute another CompletionStage
fn
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.thenComposeAsync.

Returns a new CompletionStage that is completed with the same value as the CompletionStage returned by the given function, executed using the supplied Executor.
public FutureCompletionStage<Void>
thenRun(Runnable
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.thenRun.

Returns a new CompletionStage that, when this stage completes normally, executes the given action.
public FutureCompletionStage<Void>
thenRunAsync(Runnable
the action to perform before completing the returned CompletionStage
action
)

Redeclares java.util.concurrent.CompletionStage.thenRunAsync.

Returns a new CompletionStage that, when this stage completes normally, executes the given action using this stage's default asynchronous execution facility.
public FutureCompletionStage<Void>
thenRunAsync(Runnable
the action to perform before completing the returned CompletionStage
action
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.thenRunAsync.

Returns a new CompletionStage that, when this stage completes normally, executes the given action using the supplied Executor.
public default CompletableFuture<V>
public static <U> FutureCompletionStage<U>
toFutureCompletionStage(CompletionStage<U> stage, EventExecutor executor)

Returns a FutureCompletionStage for the given CompletionStage that is pinned to the given EventExecutor.

public FutureCompletionStage<V>
whenComplete(BiConsumer<? super V, ? super Throwable>
the action to perform
action
)

Redeclares java.util.concurrent.CompletionStage.whenComplete.

Returns a new CompletionStage with the same result or exception as this stage, that executes the given action when this stage completes.
public FutureCompletionStage<V>
whenCompleteAsync(BiConsumer<? super V, ? super Throwable>
the action to perform
action
)

Redeclares java.util.concurrent.CompletionStage.whenCompleteAsync.

Returns a new CompletionStage with the same result or exception as this stage, that executes the given action using this stage's default asynchronous execution facility when this stage completes.
public FutureCompletionStage<V>
whenCompleteAsync(BiConsumer<? super V, ? super Throwable>
the action to perform
action
,
Executor
the executor to use for asynchronous execution
executor
)

Redeclares java.util.concurrent.CompletionStage.whenCompleteAsync.

Returns a new CompletionStage with the same result or exception as this stage, that executes the given action using the supplied Executor when this stage completes.
Inherited from io.netty5.util.concurrent.AsynchronousResult:
isCancelledisDone
Inherited from java.util.concurrent.CompletionStage:
exceptionallyAsyncexceptionallyAsyncexceptionallyComposeexceptionallyComposeAsyncexceptionallyComposeAsync
Inherited from java.util.concurrent.Future:
cancelexceptionNowgetgetisCancelledisDoneresultNowstate