Package com.terracottatech.store.async
Interface Operation<T>
- Type Parameters:
T
- the type of the operation result
- All Superinterfaces:
CompletionStage<T>
,Future<T>
A representation of the asynchronous execution of an operation. Asynchronous
dataset operations can be incorporated as stages of a larger computation
through use of the
CompletionStage
methods.-
Method Summary
Modifier and TypeMethodDescriptionacceptEither
(CompletionStage<? extends T> other, Consumer<? super T> action) acceptEitherAsync
(CompletionStage<? extends T> other, Consumer<? super T> action) acceptEitherAsync
(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) default <U> Operation<U>
applyToEither
(CompletionStage<? extends T> other, Function<? super T, U> fn) default <U> Operation<U>
applyToEitherAsync
(CompletionStage<? extends T> other, Function<? super T, U> fn) default <U> Operation<U>
applyToEitherAsync
(CompletionStage<? extends T> other, Function<? super T, U> fn, Executor executor) exceptionally
(Function<Throwable, ? extends T> fn) default Executor
executor()
Returns the default asynchronous execution pool for this operation.default <U> Operation<U>
handle
(BiFunction<? super T, Throwable, ? extends U> fn) default <U> Operation<U>
handleAsync
(BiFunction<? super T, Throwable, ? extends U> fn) default <U> Operation<U>
handleAsync
(BiFunction<? super T, Throwable, ? extends U> fn, Executor executor) <U> Operation<U>
Returns a new Operation that represents the synchronous mapping of this stages result using the provided function.static <T> Operation<T>
operation
(CompletableFuture<T> future) Create an operation who's completion is tied to the givenCompletableFuture
.static <T> Operation<T>
operation
(CompletableFuture<T> future, Executor executor) /** Create an operation who's completion is tied to the givenCompletableFuture
.static <T> Operation<T>
Create an operation who's completion is tied to the givenFuture
.static <T> Operation<T>
Create an operation who's completion is tied to the givenFuture
.runAfterBoth
(CompletionStage<?> other, Runnable action) runAfterBothAsync
(CompletionStage<?> other, Runnable action) runAfterBothAsync
(CompletionStage<?> other, Runnable action, Executor executor) runAfterEither
(CompletionStage<?> other, Runnable action) runAfterEitherAsync
(CompletionStage<?> other, Runnable action) runAfterEitherAsync
(CompletionStage<?> other, Runnable action, Executor executor) thenAccept
(Consumer<? super T> action) thenAcceptAsync
(Consumer<? super T> action) thenAcceptAsync
(Consumer<? super T> action, Executor executor) thenAcceptBoth
(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) thenAcceptBothAsync
(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) thenAcceptBothAsync
(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) default <U> Operation<U>
default <U> Operation<U>
thenApplyAsync
(Function<? super T, ? extends U> fn) default <U> Operation<U>
thenApplyAsync
(Function<? super T, ? extends U> fn, Executor executor) default <U,
V> Operation<V> thenCombine
(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) default <U,
V> Operation<V> thenCombineAsync
(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) default <U,
V> Operation<V> thenCombineAsync
(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) default <U> Operation<U>
thenCompose
(Function<? super T, ? extends CompletionStage<U>> fn) default <U> Operation<U>
thenComposeAsync
(Function<? super T, ? extends CompletionStage<U>> fn) default <U> Operation<U>
thenComposeAsync
(Function<? super T, ? extends CompletionStage<U>> fn, Executor executor) thenRunAsync
(Runnable action) thenRunAsync
(Runnable action, Executor executor) default CompletableFuture<T>
toCompletableFuture
(Executor executor) Returns aCompletableFuture
maintaining the same completion properties as this stage using the supplied executor for any necessary synchronous calls.usingExecutor
(Executor executor) Returns a new Operation that uses the supplied executor as it's default async executor.whenComplete
(BiConsumer<? super T, ? super Throwable> action) whenCompleteAsync
(BiConsumer<? super T, ? super Throwable> action) whenCompleteAsync
(BiConsumer<? super T, ? super Throwable> action, Executor executor) Methods inherited from interface java.util.concurrent.CompletionStage
exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync
-
Method Details
-
handleAsync
default <U> Operation<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn, Executor executor) - Specified by:
handleAsync
in interfaceCompletionStage<T>
-
handleAsync
- Specified by:
handleAsync
in interfaceCompletionStage<T>
-
handle
- Specified by:
handle
in interfaceCompletionStage<T>
-
whenCompleteAsync
default Operation<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action, Executor executor) - Specified by:
whenCompleteAsync
in interfaceCompletionStage<T>
-
whenCompleteAsync
- Specified by:
whenCompleteAsync
in interfaceCompletionStage<T>
-
whenComplete
- Specified by:
whenComplete
in interfaceCompletionStage<T>
-
exceptionally
- Specified by:
exceptionally
in interfaceCompletionStage<T>
-
thenComposeAsync
default <U> Operation<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn, Executor executor) - Specified by:
thenComposeAsync
in interfaceCompletionStage<T>
-
thenComposeAsync
- Specified by:
thenComposeAsync
in interfaceCompletionStage<T>
-
thenCompose
- Specified by:
thenCompose
in interfaceCompletionStage<T>
-
runAfterEitherAsync
default Operation<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor) - Specified by:
runAfterEitherAsync
in interfaceCompletionStage<T>
-
runAfterEitherAsync
- Specified by:
runAfterEitherAsync
in interfaceCompletionStage<T>
-
runAfterEither
- Specified by:
runAfterEither
in interfaceCompletionStage<T>
-
acceptEitherAsync
default Operation<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) - Specified by:
acceptEitherAsync
in interfaceCompletionStage<T>
-
acceptEitherAsync
default Operation<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action) - Specified by:
acceptEitherAsync
in interfaceCompletionStage<T>
-
acceptEither
default Operation<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action) - Specified by:
acceptEither
in interfaceCompletionStage<T>
-
applyToEitherAsync
default <U> Operation<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn, Executor executor) - Specified by:
applyToEitherAsync
in interfaceCompletionStage<T>
-
applyToEitherAsync
default <U> Operation<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn) - Specified by:
applyToEitherAsync
in interfaceCompletionStage<T>
-
applyToEither
default <U> Operation<U> applyToEither(CompletionStage<? extends T> other, Function<? super T, U> fn) - Specified by:
applyToEither
in interfaceCompletionStage<T>
-
runAfterBothAsync
default Operation<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor) - Specified by:
runAfterBothAsync
in interfaceCompletionStage<T>
-
runAfterBothAsync
- Specified by:
runAfterBothAsync
in interfaceCompletionStage<T>
-
runAfterBoth
- Specified by:
runAfterBoth
in interfaceCompletionStage<T>
-
thenAcceptBothAsync
default <U> Operation<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) - Specified by:
thenAcceptBothAsync
in interfaceCompletionStage<T>
-
thenAcceptBothAsync
default <U> Operation<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) - Specified by:
thenAcceptBothAsync
in interfaceCompletionStage<T>
-
thenAcceptBoth
default <U> Operation<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) - Specified by:
thenAcceptBoth
in interfaceCompletionStage<T>
-
thenCombineAsync
default <U,V> Operation<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) - Specified by:
thenCombineAsync
in interfaceCompletionStage<T>
-
thenCombineAsync
default <U,V> Operation<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) - Specified by:
thenCombineAsync
in interfaceCompletionStage<T>
-
thenCombine
default <U,V> Operation<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) - Specified by:
thenCombine
in interfaceCompletionStage<T>
-
thenRunAsync
- Specified by:
thenRunAsync
in interfaceCompletionStage<T>
-
thenRunAsync
- Specified by:
thenRunAsync
in interfaceCompletionStage<T>
-
thenRun
- Specified by:
thenRun
in interfaceCompletionStage<T>
-
thenAcceptAsync
- Specified by:
thenAcceptAsync
in interfaceCompletionStage<T>
-
thenAcceptAsync
- Specified by:
thenAcceptAsync
in interfaceCompletionStage<T>
-
thenAccept
- Specified by:
thenAccept
in interfaceCompletionStage<T>
-
thenApplyAsync
- Specified by:
thenApplyAsync
in interfaceCompletionStage<T>
-
thenApplyAsync
- Specified by:
thenApplyAsync
in interfaceCompletionStage<T>
-
thenApply
- Specified by:
thenApply
in interfaceCompletionStage<T>
-
map
Returns a new Operation that represents the synchronous mapping of this stages result using the provided function.- Type Parameters:
U
- the function's return type- Parameters:
fn
- the mapping function- Returns:
- a new Operation
-
usingExecutor
Returns a new Operation that uses the supplied executor as it's default async executor.- Parameters:
executor
- async executor- Returns:
- a new Operation
-
executor
Returns the default asynchronous execution pool for this operation.- Returns:
- the default asynchronous execution pool
-
toCompletableFuture
- Specified by:
toCompletableFuture
in interfaceCompletionStage<T>
-
toCompletableFuture
Returns aCompletableFuture
maintaining the same completion properties as this stage using the supplied executor for any necessary synchronous calls.- Parameters:
executor
- executor for sync calls- Returns:
- the CompletableFuture
-
operation
Create an operation who's completion is tied to the givenCompletableFuture
.Default async execution mode operations against the returned operation will use the invoking pool (if there is one) or the
ForkJoinPool.commonPool()
to poll the future when necessary.- Type Parameters:
T
- the operations result type- Parameters:
future
- underlying completable future- Returns:
- a new operation
-
operation
/** Create an operation who's completion is tied to the givenCompletableFuture
.Default async execution mode operations against the returned operation will use the supplied executor.
- Type Parameters:
T
- the operations result type- Parameters:
future
- underlying completable futureexecutor
- default async executor- Returns:
- a new operation
-
operation
Create an operation who's completion is tied to the givenFuture
.Default async execution mode operations against the returned operation will use the invoking pool (if there is one) or the
ForkJoinPool.commonPool()
to poll the future when necessary.- Type Parameters:
T
- the operations result type- Parameters:
future
- underlying future- Returns:
- a new operation
-
operation
Create an operation who's completion is tied to the givenFuture
.Default async execution mode operations against the returned operation will use the supplied executor.
- Type Parameters:
T
- the operations result type- Parameters:
future
- underlying futureexecutor
- default async executor- Returns:
- a new operation
-