Package io.smallrye.context
Class CompletableFutureWrapper<T>
- java.lang.Object
-
- java.util.concurrent.CompletableFuture<T>
-
- io.smallrye.context.CompletableFutureWrapper<T>
-
- All Implemented Interfaces:
Contextualized
,CompletionStage<T>
,Future<T>
public class CompletableFutureWrapper<T> extends CompletableFuture<T> implements Contextualized
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask
-
-
Field Summary
Fields Modifier and Type Field Description protected SmallRyeThreadContext
context
protected Executor
executor
If this executor is not null, we're wrapping a CF.protected CompletableFuture<T>
f
static int
FLAG_DEPENDENT
static int
FLAG_MINIMAL
protected int
flags
-
Constructor Summary
Constructors Constructor Description CompletableFutureWrapper(SmallRyeThreadContext context, CompletableFuture<T> f, Executor executor, int flags)
-
Method Summary
-
Methods inherited from class java.util.concurrent.CompletableFuture
allOf, anyOf, completeAsync, completeAsync, completedFuture, completedStage, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, failedFuture, failedStage, minimalCompletionStage, newIncompleteFuture, orTimeout, runAsync, runAsync, supplyAsync, supplyAsync
-
-
-
-
Field Detail
-
f
protected final CompletableFuture<T> f
-
context
protected final SmallRyeThreadContext context
-
executor
protected final Executor executor
If this executor is not null, we're wrapping a CF. If it is null, we're a dependent stage of another CF, so we have different behaviour
-
flags
protected final int flags
-
FLAG_MINIMAL
public static final int FLAG_MINIMAL
- See Also:
- Constant Field Values
-
FLAG_DEPENDENT
public static final int FLAG_DEPENDENT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CompletableFutureWrapper
public CompletableFutureWrapper(SmallRyeThreadContext context, CompletableFuture<T> f, Executor executor, int flags)
-
-
Method Detail
-
complete
public boolean complete(T value)
- Overrides:
complete
in classCompletableFuture<T>
-
completeExceptionally
public boolean completeExceptionally(Throwable ex)
- Overrides:
completeExceptionally
in classCompletableFuture<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfaceFuture<T>
- Overrides:
isCancelled
in classCompletableFuture<T>
-
isCompletedExceptionally
public boolean isCompletedExceptionally()
- Overrides:
isCompletedExceptionally
in classCompletableFuture<T>
-
obtrudeValue
public void obtrudeValue(T value)
- Overrides:
obtrudeValue
in classCompletableFuture<T>
-
obtrudeException
public void obtrudeException(Throwable ex)
- Overrides:
obtrudeException
in classCompletableFuture<T>
-
getNumberOfDependents
public int getNumberOfDependents()
- Overrides:
getNumberOfDependents
in classCompletableFuture<T>
-
isDone
public boolean isDone()
-
get
public T get() throws InterruptedException, ExecutionException
- Specified by:
get
in interfaceFuture<T>
- Overrides:
get
in classCompletableFuture<T>
- Throws:
InterruptedException
ExecutionException
-
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
get
in interfaceFuture<T>
- Overrides:
get
in classCompletableFuture<T>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
join
public T join()
- Overrides:
join
in classCompletableFuture<T>
-
getNow
public T getNow(T valueIfAbsent)
- Overrides:
getNow
in classCompletableFuture<T>
-
toCompletableFuture
public CompletableFuture<T> toCompletableFuture()
- Specified by:
toCompletableFuture
in interfaceCompletionStage<T>
- Overrides:
toCompletableFuture
in classCompletableFuture<T>
-
exceptionally
public CompletableFuture<T> exceptionally(Function<Throwable,? extends T> fn)
- Specified by:
exceptionally
in interfaceCompletionStage<T>
- Overrides:
exceptionally
in classCompletableFuture<T>
-
handle
public <U> CompletableFuture<U> handle(BiFunction<? super T,Throwable,? extends U> fn)
- Specified by:
handle
in interfaceCompletionStage<T>
- Overrides:
handle
in classCompletableFuture<T>
-
handleAsync
public <U> CompletableFuture<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn)
- Specified by:
handleAsync
in interfaceCompletionStage<T>
- Overrides:
handleAsync
in classCompletableFuture<T>
-
handleAsync
public <U> CompletableFuture<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn, Executor executor)
- Specified by:
handleAsync
in interfaceCompletionStage<T>
- Overrides:
handleAsync
in classCompletableFuture<T>
-
thenApply
public <U> CompletableFuture<U> thenApply(Function<? super T,? extends U> fn)
- Specified by:
thenApply
in interfaceCompletionStage<T>
- Overrides:
thenApply
in classCompletableFuture<T>
-
thenApplyAsync
public <U> CompletableFuture<U> thenApplyAsync(Function<? super T,? extends U> fn)
- Specified by:
thenApplyAsync
in interfaceCompletionStage<T>
- Overrides:
thenApplyAsync
in classCompletableFuture<T>
-
thenApplyAsync
public <U> CompletableFuture<U> thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)
- Specified by:
thenApplyAsync
in interfaceCompletionStage<T>
- Overrides:
thenApplyAsync
in classCompletableFuture<T>
-
thenAccept
public CompletableFuture<Void> thenAccept(Consumer<? super T> action)
- Specified by:
thenAccept
in interfaceCompletionStage<T>
- Overrides:
thenAccept
in classCompletableFuture<T>
-
thenAcceptAsync
public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> action)
- Specified by:
thenAcceptAsync
in interfaceCompletionStage<T>
- Overrides:
thenAcceptAsync
in classCompletableFuture<T>
-
thenAcceptAsync
public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> action, Executor executor)
- Specified by:
thenAcceptAsync
in interfaceCompletionStage<T>
- Overrides:
thenAcceptAsync
in classCompletableFuture<T>
-
thenRun
public CompletableFuture<Void> thenRun(Runnable action)
- Specified by:
thenRun
in interfaceCompletionStage<T>
- Overrides:
thenRun
in classCompletableFuture<T>
-
thenRunAsync
public CompletableFuture<Void> thenRunAsync(Runnable action)
- Specified by:
thenRunAsync
in interfaceCompletionStage<T>
- Overrides:
thenRunAsync
in classCompletableFuture<T>
-
thenRunAsync
public CompletableFuture<Void> thenRunAsync(Runnable action, Executor executor)
- Specified by:
thenRunAsync
in interfaceCompletionStage<T>
- Overrides:
thenRunAsync
in classCompletableFuture<T>
-
thenCombine
public <U,V> CompletableFuture<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
- Specified by:
thenCombine
in interfaceCompletionStage<T>
- Overrides:
thenCombine
in classCompletableFuture<T>
-
thenCombineAsync
public <U,V> CompletableFuture<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
- Specified by:
thenCombineAsync
in interfaceCompletionStage<T>
- Overrides:
thenCombineAsync
in classCompletableFuture<T>
-
thenCombineAsync
public <U,V> CompletableFuture<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn, Executor executor)
- Specified by:
thenCombineAsync
in interfaceCompletionStage<T>
- Overrides:
thenCombineAsync
in classCompletableFuture<T>
-
thenAcceptBoth
public <U> CompletableFuture<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
- Specified by:
thenAcceptBoth
in interfaceCompletionStage<T>
- Overrides:
thenAcceptBoth
in classCompletableFuture<T>
-
thenAcceptBothAsync
public <U> CompletableFuture<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
- Specified by:
thenAcceptBothAsync
in interfaceCompletionStage<T>
- Overrides:
thenAcceptBothAsync
in classCompletableFuture<T>
-
thenAcceptBothAsync
public <U> CompletableFuture<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action, Executor executor)
- Specified by:
thenAcceptBothAsync
in interfaceCompletionStage<T>
- Overrides:
thenAcceptBothAsync
in classCompletableFuture<T>
-
runAfterBoth
public CompletableFuture<Void> runAfterBoth(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterBoth
in interfaceCompletionStage<T>
- Overrides:
runAfterBoth
in classCompletableFuture<T>
-
runAfterBothAsync
public CompletableFuture<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterBothAsync
in interfaceCompletionStage<T>
- Overrides:
runAfterBothAsync
in classCompletableFuture<T>
-
runAfterBothAsync
public CompletableFuture<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)
- Specified by:
runAfterBothAsync
in interfaceCompletionStage<T>
- Overrides:
runAfterBothAsync
in classCompletableFuture<T>
-
applyToEither
public <U> CompletableFuture<U> applyToEither(CompletionStage<? extends T> other, Function<? super T,U> fn)
- Specified by:
applyToEither
in interfaceCompletionStage<T>
- Overrides:
applyToEither
in classCompletableFuture<T>
-
applyToEitherAsync
public <U> CompletableFuture<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn)
- Specified by:
applyToEitherAsync
in interfaceCompletionStage<T>
- Overrides:
applyToEitherAsync
in classCompletableFuture<T>
-
applyToEitherAsync
public <U> CompletableFuture<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn, Executor executor)
- Specified by:
applyToEitherAsync
in interfaceCompletionStage<T>
- Overrides:
applyToEitherAsync
in classCompletableFuture<T>
-
acceptEither
public CompletableFuture<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
- Specified by:
acceptEither
in interfaceCompletionStage<T>
- Overrides:
acceptEither
in classCompletableFuture<T>
-
acceptEitherAsync
public CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
- Specified by:
acceptEitherAsync
in interfaceCompletionStage<T>
- Overrides:
acceptEitherAsync
in classCompletableFuture<T>
-
acceptEitherAsync
public CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)
- Specified by:
acceptEitherAsync
in interfaceCompletionStage<T>
- Overrides:
acceptEitherAsync
in classCompletableFuture<T>
-
runAfterEither
public CompletableFuture<Void> runAfterEither(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterEither
in interfaceCompletionStage<T>
- Overrides:
runAfterEither
in classCompletableFuture<T>
-
runAfterEitherAsync
public CompletableFuture<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterEitherAsync
in interfaceCompletionStage<T>
- Overrides:
runAfterEitherAsync
in classCompletableFuture<T>
-
runAfterEitherAsync
public CompletableFuture<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)
- Specified by:
runAfterEitherAsync
in interfaceCompletionStage<T>
- Overrides:
runAfterEitherAsync
in classCompletableFuture<T>
-
thenCompose
public <U> CompletableFuture<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
- Specified by:
thenCompose
in interfaceCompletionStage<T>
- Overrides:
thenCompose
in classCompletableFuture<T>
-
thenComposeAsync
public <U> CompletableFuture<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
- Specified by:
thenComposeAsync
in interfaceCompletionStage<T>
- Overrides:
thenComposeAsync
in classCompletableFuture<T>
-
thenComposeAsync
public <U> CompletableFuture<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn, Executor executor)
- Specified by:
thenComposeAsync
in interfaceCompletionStage<T>
- Overrides:
thenComposeAsync
in classCompletableFuture<T>
-
whenComplete
public CompletableFuture<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
- Specified by:
whenComplete
in interfaceCompletionStage<T>
- Overrides:
whenComplete
in classCompletableFuture<T>
-
whenCompleteAsync
public CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
- Specified by:
whenCompleteAsync
in interfaceCompletionStage<T>
- Overrides:
whenCompleteAsync
in classCompletableFuture<T>
-
whenCompleteAsync
public CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor)
- Specified by:
whenCompleteAsync
in interfaceCompletionStage<T>
- Overrides:
whenCompleteAsync
in classCompletableFuture<T>
-
toString
public String toString()
- Overrides:
toString
in classCompletableFuture<T>
-
-