T - the type of the returned object.CompletionStage<T>, Future<T>public class Task<T> extends CompletableFuture<T>
CompletableFutureCompletableFuture.AsynchronousCompletionTask| Constructor | Description |
|---|---|
Task() |
| Modifier and Type | Method | Description |
|---|---|---|
Task<Void> |
acceptEither(CompletionStage<? extends T> completionStage,
Consumer<? super T> consumer) |
|
Task<Void> |
acceptEitherAsync(CompletionStage<? extends T> completionStage,
Consumer<? super T> consumer) |
|
Task<Void> |
acceptEitherAsync(CompletionStage<? extends T> completionStage,
Consumer<? super T> consumer,
Executor executor) |
|
static <F extends CompletableFuture<?>,C extends Collection<F>> |
allOf(C cfs) |
|
static Task<Void> |
allOf(CompletableFuture<?>... cfs) |
|
static <F extends CompletableFuture<?>> |
allOf(Stream<F> cfs) |
|
static <F extends CompletableFuture<?>> |
anyOf(Collection<F> cfs) |
|
static Task<Object> |
anyOf(CompletableFuture<?>... cfs) |
|
static <F extends CompletableFuture<?>> |
anyOf(Stream<F> cfs) |
|
<U> Task<U> |
applyToEither(CompletionStage<? extends T> completionStage,
Function<? super T,U> function) |
|
<U> Task<U> |
applyToEitherAsync(CompletionStage<? extends T> completionStage,
Function<? super T,U> function) |
|
<U> Task<U> |
applyToEitherAsync(CompletionStage<? extends T> completionStage,
Function<? super T,U> function,
Executor executor) |
|
boolean |
complete(T value) |
This completableFuture derived method is not available for Tasks.
|
boolean |
completeExceptionally(Throwable ex) |
This completableFuture derived method is not available for Tasks.
|
static Task<Void> |
done() |
|
Task<T> |
exceptionally(Function<Throwable,? extends T> fn) |
|
Task<T> |
failAfter(long timeout,
TimeUnit timeUnit) |
Returns a new task that will fail if the original is not completed withing the given timeout.
|
static <T> Task<T> |
from(CompletionStage<T> stage) |
Wraps a CompletionStage as a Task or just casts it if it is already a Task.
|
static <T> Task<T> |
fromException(Throwable ex) |
|
static <T> Task<T> |
fromFuture(Future<T> future) |
Wraps a Future as a Task or just casts it if it is already a Task.
|
static <T> Task<T> |
fromValue(T value) |
Creates an already completed task from the given value.
|
<U> Task<U> |
handle(BiFunction<? super T,Throwable,? extends U> fn) |
|
<U> Task<U> |
handleAsync(BiFunction<? super T,Throwable,? extends U> biFunction) |
|
<U> Task<U> |
handleAsync(BiFunction<? super T,Throwable,? extends U> biFunction,
Executor executor) |
|
protected boolean |
internalComplete(T value) |
|
protected boolean |
internalCompleteExceptionally(Throwable ex) |
|
Task<Void> |
runAfterBoth(CompletionStage<?> completionStage,
Runnable runnable) |
|
Task<Void> |
runAfterBothAsync(CompletionStage<?> completionStage,
Runnable runnable) |
|
Task<Void> |
runAfterBothAsync(CompletionStage<?> completionStage,
Runnable runnable,
Executor executor) |
|
Task<Void> |
runAfterEither(CompletionStage<?> completionStage,
Runnable runnable) |
|
Task<Void> |
runAfterEitherAsync(CompletionStage<?> completionStage,
Runnable runnable) |
|
Task<Void> |
runAfterEitherAsync(CompletionStage<?> completionStage,
Runnable runnable,
Executor executor) |
|
static Task<Void> |
runAsync(Runnable runnable) |
|
static Task<Void> |
runAsync(Runnable runnable,
Executor executor) |
|
static Task<Void> |
sleep(long time,
TimeUnit timeUnit) |
Returns a new task that will fail if the original is not completed withing the given timeout.
|
static <U> Task<U> |
supplyAsync(TaskSupplier<U> supplier) |
|
static <U> Task<U> |
supplyAsync(TaskSupplier<U> supplier,
Executor executor) |
|
static <U> Task<U> |
supplyAsync(Supplier<U> supplier) |
|
static <U> Task<U> |
supplyAsync(Supplier<U> supplier,
Executor executor) |
|
Task<Void> |
thenAccept(Consumer<? super T> action) |
|
Task<Void> |
thenAcceptAsync(Consumer<? super T> consumer) |
|
Task<Void> |
thenAcceptAsync(Consumer<? super T> consumer,
Executor executor) |
|
<U> Task<Void> |
thenAcceptBoth(CompletionStage<? extends U> completionStage,
BiConsumer<? super T,? super U> biConsumer) |
|
<U> Task<Void> |
thenAcceptBothAsync(CompletionStage<? extends U> completionStage,
BiConsumer<? super T,? super U> biConsumer) |
|
<U> Task<Void> |
thenAcceptBothAsync(CompletionStage<? extends U> completionStage,
BiConsumer<? super T,? super U> biConsumer,
Executor executor) |
|
<U> Task<U> |
thenApply(Function<? super T,? extends U> fn) |
|
<U> Task<U> |
thenApplyAsync(Function<? super T,? extends U> function) |
|
<U> Task<U> |
thenApplyAsync(Function<? super T,? extends U> function,
Executor executor) |
|
<U,V> Task<V> |
thenCombine(CompletionStage<? extends U> completionStage,
BiFunction<? super T,? super U,? extends V> biFunction) |
|
<U,V> Task<V> |
thenCombineAsync(CompletionStage<? extends U> completionStage,
BiFunction<? super T,? super U,? extends V> biFunction) |
|
<U,V> Task<V> |
thenCombineAsync(CompletionStage<? extends U> completionStage,
BiFunction<? super T,? super U,? extends V> biFunction,
Executor executor) |
|
<U> Task<U> |
thenCompose(Function<? super T,? extends CompletionStage<U>> fn) |
|
<U> Task<U> |
thenCompose(Supplier<? extends CompletionStage<U>> fn) |
|
<U> Task<U> |
thenComposeAsync(Function<? super T,? extends CompletionStage<U>> function) |
|
<U> Task<U> |
thenComposeAsync(Function<? super T,? extends CompletionStage<U>> function,
Executor executor) |
|
<U> Task<U> |
thenReturn(Supplier<U> supplier) |
Returns a new Task that is executed when this task completes normally.
|
Task<Void> |
thenRun(Runnable action) |
|
Task<Void> |
thenRunAsync(Runnable runnable) |
|
Task<Void> |
thenRunAsync(Runnable runnable,
Executor executor) |
|
Task<T> |
whenComplete(BiConsumer<? super T,? super Throwable> action) |
|
Task<T> |
whenCompleteAsync(BiConsumer<? super T,? super Throwable> biConsumer) |
|
Task<T> |
whenCompleteAsync(BiConsumer<? super T,? super Throwable> biConsumer,
Executor executor) |
cancel, completeAsync, completeAsync, completedFuture, completedStage, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, toCompletableFuture, toStringpublic static <T> Task<T> fromValue(T value)
value - the value to be wrapped with a taskprotected boolean internalComplete(T value)
protected boolean internalCompleteExceptionally(Throwable ex)
public boolean complete(T value)
complete in class CompletableFuture<T>public boolean completeExceptionally(Throwable ex)
completeExceptionally in class CompletableFuture<T>public static <T> Task<T> from(CompletionStage<T> stage)
stage - the stage to be wrapped or casted to Taskpublic static <T> Task<T> fromFuture(Future<T> future)
If future implements CompletionStage CompletionStage.handle will be used.
If future is a plain old future, a runnable will executed using a default task pool. This runnable will wait on the future using Future.get(timeout,timeUnit), with a timeout of 5ms. Every time this task times out it will be rescheduled. Starvation of the pool is prevented by the rescheduling behaviour.
future - the future to be wrapped or casted to Taskpublic Task<T> failAfter(long timeout, TimeUnit timeUnit)
Task<String> result = aTask.failAfter(60, TimeUnit.SECONDS);timeout - the time from nowtimeUnit - the time unit of the timeout parameterpublic static Task<Void> sleep(long time, TimeUnit timeUnit)
time - the time from nowtimeUnit - the time unit of the timeout parameterpublic <U> Task<U> thenApply(Function<? super T,? extends U> fn)
thenApply in interface CompletionStage<T>thenApply in class CompletableFuture<T>public Task<Void> thenAccept(Consumer<? super T> action)
thenAccept in interface CompletionStage<T>thenAccept in class CompletableFuture<T>public Task<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
whenComplete in interface CompletionStage<T>whenComplete in class CompletableFuture<T>public <U> Task<U> thenReturn(Supplier<U> supplier)
CompletionStage documentation for rules
covering exceptional completion.U - the supplier's return typesupplier - the Supplier that will provider the value
the returned Taskpublic <U> Task<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
thenCompose in interface CompletionStage<T>thenCompose in class CompletableFuture<T>public <U> Task<U> thenCompose(Supplier<? extends CompletionStage<U>> fn)
public <U> Task<U> handle(BiFunction<? super T,Throwable,? extends U> fn)
handle in interface CompletionStage<T>handle in class CompletableFuture<T>public Task<T> exceptionally(Function<Throwable,? extends T> fn)
exceptionally in interface CompletionStage<T>exceptionally in class CompletableFuture<T>public Task<Void> thenRun(Runnable action)
thenRun in interface CompletionStage<T>thenRun in class CompletableFuture<T>public Task<Void> acceptEither(CompletionStage<? extends T> completionStage, Consumer<? super T> consumer)
acceptEither in interface CompletionStage<T>acceptEither in class CompletableFuture<T>public Task<Void> acceptEitherAsync(CompletionStage<? extends T> completionStage, Consumer<? super T> consumer)
acceptEitherAsync in interface CompletionStage<T>acceptEitherAsync in class CompletableFuture<T>public Task<Void> acceptEitherAsync(CompletionStage<? extends T> completionStage, Consumer<? super T> consumer, Executor executor)
acceptEitherAsync in interface CompletionStage<T>acceptEitherAsync in class CompletableFuture<T>public <U> Task<U> applyToEither(CompletionStage<? extends T> completionStage, Function<? super T,U> function)
applyToEither in interface CompletionStage<T>applyToEither in class CompletableFuture<T>public <U> Task<U> applyToEitherAsync(CompletionStage<? extends T> completionStage, Function<? super T,U> function, Executor executor)
applyToEitherAsync in interface CompletionStage<T>applyToEitherAsync in class CompletableFuture<T>public <U> Task<U> applyToEitherAsync(CompletionStage<? extends T> completionStage, Function<? super T,U> function)
applyToEitherAsync in interface CompletionStage<T>applyToEitherAsync in class CompletableFuture<T>public <U> Task<U> handleAsync(BiFunction<? super T,Throwable,? extends U> biFunction, Executor executor)
handleAsync in interface CompletionStage<T>handleAsync in class CompletableFuture<T>public <U> Task<U> handleAsync(BiFunction<? super T,Throwable,? extends U> biFunction)
handleAsync in interface CompletionStage<T>handleAsync in class CompletableFuture<T>public Task<Void> runAfterBoth(CompletionStage<?> completionStage, Runnable runnable)
runAfterBoth in interface CompletionStage<T>runAfterBoth in class CompletableFuture<T>public Task<Void> runAfterBothAsync(CompletionStage<?> completionStage, Runnable runnable)
runAfterBothAsync in interface CompletionStage<T>runAfterBothAsync in class CompletableFuture<T>public Task<Void> runAfterBothAsync(CompletionStage<?> completionStage, Runnable runnable, Executor executor)
runAfterBothAsync in interface CompletionStage<T>runAfterBothAsync in class CompletableFuture<T>public Task<Void> runAfterEither(CompletionStage<?> completionStage, Runnable runnable)
runAfterEither in interface CompletionStage<T>runAfterEither in class CompletableFuture<T>public Task<Void> runAfterEitherAsync(CompletionStage<?> completionStage, Runnable runnable)
runAfterEitherAsync in interface CompletionStage<T>runAfterEitherAsync in class CompletableFuture<T>public Task<Void> runAfterEitherAsync(CompletionStage<?> completionStage, Runnable runnable, Executor executor)
runAfterEitherAsync in interface CompletionStage<T>runAfterEitherAsync in class CompletableFuture<T>public static <U> Task<U> supplyAsync(TaskSupplier<U> supplier)
public static <U> Task<U> supplyAsync(TaskSupplier<U> supplier, Executor executor)
public Task<Void> thenAcceptAsync(Consumer<? super T> consumer, Executor executor)
thenAcceptAsync in interface CompletionStage<T>thenAcceptAsync in class CompletableFuture<T>public Task<Void> thenAcceptAsync(Consumer<? super T> consumer)
thenAcceptAsync in interface CompletionStage<T>thenAcceptAsync in class CompletableFuture<T>public <U> Task<Void> thenAcceptBoth(CompletionStage<? extends U> completionStage, BiConsumer<? super T,? super U> biConsumer)
thenAcceptBoth in interface CompletionStage<T>thenAcceptBoth in class CompletableFuture<T>public <U> Task<Void> thenAcceptBothAsync(CompletionStage<? extends U> completionStage, BiConsumer<? super T,? super U> biConsumer, Executor executor)
thenAcceptBothAsync in interface CompletionStage<T>thenAcceptBothAsync in class CompletableFuture<T>public <U> Task<Void> thenAcceptBothAsync(CompletionStage<? extends U> completionStage, BiConsumer<? super T,? super U> biConsumer)
thenAcceptBothAsync in interface CompletionStage<T>thenAcceptBothAsync in class CompletableFuture<T>public <U> Task<U> thenApplyAsync(Function<? super T,? extends U> function, Executor executor)
thenApplyAsync in interface CompletionStage<T>thenApplyAsync in class CompletableFuture<T>public <U> Task<U> thenApplyAsync(Function<? super T,? extends U> function)
thenApplyAsync in interface CompletionStage<T>thenApplyAsync in class CompletableFuture<T>public <U,V> Task<V> thenCombine(CompletionStage<? extends U> completionStage, BiFunction<? super T,? super U,? extends V> biFunction)
thenCombine in interface CompletionStage<T>thenCombine in class CompletableFuture<T>public <U,V> Task<V> thenCombineAsync(CompletionStage<? extends U> completionStage, BiFunction<? super T,? super U,? extends V> biFunction, Executor executor)
thenCombineAsync in interface CompletionStage<T>thenCombineAsync in class CompletableFuture<T>public <U,V> Task<V> thenCombineAsync(CompletionStage<? extends U> completionStage, BiFunction<? super T,? super U,? extends V> biFunction)
thenCombineAsync in interface CompletionStage<T>thenCombineAsync in class CompletableFuture<T>public <U> Task<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> function, Executor executor)
thenComposeAsync in interface CompletionStage<T>thenComposeAsync in class CompletableFuture<T>public <U> Task<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> function)
thenComposeAsync in interface CompletionStage<T>thenComposeAsync in class CompletableFuture<T>public Task<Void> thenRunAsync(Runnable runnable)
thenRunAsync in interface CompletionStage<T>thenRunAsync in class CompletableFuture<T>public Task<Void> thenRunAsync(Runnable runnable, Executor executor)
thenRunAsync in interface CompletionStage<T>thenRunAsync in class CompletableFuture<T>public Task<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> biConsumer)
whenCompleteAsync in interface CompletionStage<T>whenCompleteAsync in class CompletableFuture<T>public Task<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> biConsumer, Executor executor)
whenCompleteAsync in interface CompletionStage<T>whenCompleteAsync in class CompletableFuture<T>public static Task<Void> allOf(CompletableFuture<?>... cfs)
NullPointerException - if the array or any of its elements are
nullpublic static <F extends CompletableFuture<?>,C extends Collection<F>> Task<Void> allOf(C cfs)
NullPointerException - if the collection or any of its elements are
nullpublic static <F extends CompletableFuture<?>> Task<Void> allOf(Stream<F> cfs)
NullPointerException - if the stream or any of its elements are
nullpublic static Task<Object> anyOf(CompletableFuture<?>... cfs)
NullPointerException - if the array or any of its elements are
nullpublic static <F extends CompletableFuture<?>> Task<Object> anyOf(Collection<F> cfs)
NullPointerException - if the collection or any of its elements are
nullpublic static <F extends CompletableFuture<?>> Task<Object> anyOf(Stream<F> cfs)
NullPointerException - if the stream or any of its elements are
nullCopyright © 2018 Electronic Arts Inc. All rights reserved.