Class CompetitiveFuture<T>
java.lang.Object
java.util.concurrent.CompletableFuture<T>
space.arim.omnibus.util.concurrent.CompetitiveFuture<T>
- Type Parameters:
T- the result type of the future
- All Implemented Interfaces:
CompletionStage<T>, Future<T>
A CompletableFuture with a specified default executor, which is used as the default
executor in all future async operations.
- Author:
- A248
-
Nested Class Summary
Nested classes/interfaces inherited from class CompletableFuture
CompletableFuture.AsynchronousCompletionTask -
Constructor Summary
ConstructorsConstructorDescriptionCompetitiveFuture(Executor defaultExecutor) Creates an incomplete future from the default executor to use -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CompetitiveFuture<T> completedFuture(T value, Executor defaultExecutor) Creates a precompleted future with the specified value.static <T> CompetitiveFuture<T> failedFuture(Throwable ex, Executor defaultExecutor) Creates a future completed exceptionally with the specified exception.<U> CompletableFuture<U> static CompetitiveFuture<Void> Runs an action asynchronously.static <T> CompetitiveFuture<T> supplyAsync(Supplier<T> supplier, Executor defaultExecutor) Supplies a value asynchronously.Methods inherited from class CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, delayedExecutor, delayedExecutor, exceptionally, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
-
Constructor Details
-
CompetitiveFuture
Creates an incomplete future from the default executor to use- Parameters:
defaultExecutor- the default executor for asynchronous operations- Throws:
NullPointerException- ifdefaultExecutoris null
-
-
Method Details
-
newIncompleteFuture
- Overrides:
newIncompleteFuturein classCompletableFuture<T>
-
defaultExecutor
- Overrides:
defaultExecutorin classCompletableFuture<T>
-
runAsync
Runs an action asynchronously. SeeCompletableFuture.runAsync(Runnable).
If the specified default executor is null, the common ForkJoinPool is used.- Parameters:
command- what to dodefaultExecutor- the default executor used for async methods not specifying an executor- Returns:
- a competitive future running the specified command
-
supplyAsync
Supplies a value asynchronously. SeeCompletableFuture.supplyAsync(Supplier).
If the specified default executor is null, the common ForkJoinPool is used.- Type Parameters:
T- the type of the future- Parameters:
supplier- the supplier from which to get the valuedefaultExecutor- the default executor used for async methods not specifying an executor- Returns:
- a competitive future supplying a value via the specified supplier
-
completedFuture
Creates a precompleted future with the specified value.- Type Parameters:
T- the type of the future- Parameters:
value- the value with which to complete itdefaultExecutor- the default executor used for async methods not specifying an executor- Returns:
- a competitive future completed with the specified value
-
failedFuture
Creates a future completed exceptionally with the specified exception.- Type Parameters:
T- the type of the future- Parameters:
ex- the exception with which to complete itdefaultExecutor- the default executor, used for async methods not specifying an executor- Returns:
- a competitive future completed exceptionally with the specified exception
-