Class CffuFactory
CffuFactory
is equivalent to CompletableFuture
,
contains the static (factory) methods of CompletableFuture
.
The methods that equivalent to the instance methods of CompletableFuture
is in Cffu
class.
Use builder(Executor)
to config and build CffuFactory
.
About factory methods convention of CffuFactory
:
- factory methods return
Cffu
instead ofCompletableFuture
. - only provide varargs methods for multiple Cffu/CF input arguments;
if you have
List
input, use static utility methodscffuListToArray(List)
orCompletableFutureUtils.completableFutureListToArray(List)
to convert it to array first.
- Author:
- Jerry Lee (oldratlee at gmail dot com), HuHao (995483610 at qq dot com)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionallFailFastOf
(CompletionStage<?>... cfs) Returns a new Cffu that is completed normally when all the given stages complete normally; If any of the given stages complete exceptionally, then the returned Cffu also does so, WITHOUT waiting other incomplete given stages, with a CompletionException holding this exception as its cause.allOf
(CompletionStage<?>... cfs) Returns a new Cffu that is completed when all the given stages complete; If any of the given stages complete exceptionally, then the returned Cffu also does so, with a CompletionException holding this exception as its cause.allResultsFailFastOf
(CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed normally with a list containing the successful results of all given stages when all the given stages complete normally; If any of the given stages complete exceptionally, then the returned Cffu also does so, WITHOUT waiting other incomplete given stages, with a CompletionException holding this exception as its cause.allResultsOf
(CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed normally with a list containing the successful results of all given stages when all the given stages complete; If any of the given stages complete exceptionally, then the returned Cffu also does so, with a CompletionException holding this exception as its cause.allSuccessResultsOf
(T valueIfFailed, CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed normally with a list containing the successful results of all given stages when all the given stages complete; The list of results is in the same order as the input list, and if any of given stages complete exceptionally, their corresponding position will containvalueIfFailed
(which is indistinguishable from the stage having a successful value ofvalueIfFailed
).allSuccessTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Tuple variant ofallSuccessResultsOf(Object, CompletionStage[])
withnull
valueIfFailed.allSuccessTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Tuple variant ofallSuccessResultsOf(Object, CompletionStage[])
withnull
valueIfFailed.allSuccessTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Tuple variant ofallSuccessResultsOf(Object, CompletionStage[])
withnull
valueIfFailed.allSuccessTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Tuple variant ofallSuccessResultsOf(Object, CompletionStage[])
withnull
valueIfFailed.allTupleFailFastOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Tuple variant ofallResultsFailFastOf(CompletionStage[])
.allTupleFailFastOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Tuple variant ofallResultsFailFastOf(CompletionStage[])
.allTupleFailFastOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Tuple variant ofallResultsFailFastOf(CompletionStage[])
.allTupleFailFastOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Tuple variant ofallResultsFailFastOf(CompletionStage[])
.allTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Tuple variant ofallResultsOf(CompletionStage[])
.allTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Tuple variant ofallResultsOf(CompletionStage[])
.allTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Tuple variant ofallResultsOf(CompletionStage[])
.allTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Tuple variant ofallResultsOf(CompletionStage[])
.final <T> Cffu
<T> anyOf
(CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed with the same successful result or exception of any of the given stages when one stage completes.final <T> Cffu
<T> anySuccessOf
(CompletionStage<? extends T>... cfs) Returns a new Cffu that completed normally when any of the given stages complete normally, with the same result; Otherwise, when all the given stages complete exceptionally, the returned Cffu also does so, with a CompletionException holding an exception from any of the given stages as its cause.static CffuFactoryBuilder
Returns aCffuFactoryBuilder
withdefaultExecutor
setting.static <T> Cffu<T>[]
cffuListToArray
(List<Cffu<T>> cffuList) Convert Cffu list to Cffu array.<T> Cffu
<T> completedFuture
(T value) Returns a new Cffu that is already completed with the given value.<T> CompletionStage
<T> completedStage
(T value) Returns a new CompletionStage that is already completed with the given value and supports only those methods in interfaceCompletionStage
.Returns the default Executor used for async methods that do not specify an Executor.delayedExecutor
(long delay, TimeUnit unit) Returns a new Executor that submits a task to the default executor after the given delay (or no delay if non-positive).delayedExecutor
(long delay, TimeUnit unit, Executor executor) Returns a new Executor that submits a task to the given base executor after the given delay (or no delay if non-positive).<T> Cffu
<T> Returns a new Cffu that is already completed exceptionally with the given exception.<T> CompletionStage
<T> failedStage
(Throwable ex) Returns a new CompletionStage that is already completed exceptionally with the given exception and supports only those methods in interfaceCompletionStage
.boolean
ReturnsforbidObtrudeMethods
or not.mostSuccessResultsOf
(T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed normally with a list containing the successful results of the given stages before the given timeout (aka as many results as possible in the given time); The list of results is in the same order as the input list, and if any of given stages complete exceptionally or are incomplete, their corresponding positions will containvalueIfNotSuccess
(which is indistinguishable from the stage having a successful value ofvalueIfNotSuccess
).mostSuccessTupleOf
(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Tuple variant ofmostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])
withnull
valueIfNotSuccess.mostSuccessTupleOf
(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Tuple variant ofmostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])
withnull
valueIfNotSuccess.mostSuccessTupleOf
(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Tuple variant ofmostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])
withnull
valueIfNotSuccess.mostSuccessTupleOf
(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Tuple variant ofmostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])
withnull
valueIfNotSuccess.mRunAnyAsync
(Runnable... actions) Shortcut to methodanyOf
, wraps input actions to Cffu byrunAsync(Runnable)
.mRunAnyAsync
(Executor executor, Runnable... actions) Shortcut to methodanyOf
, wraps input actions to Cffu byrunAsync(Runnable, Executor)
.mRunAnySuccessAsync
(Runnable... actions) Shortcut to methodanySuccessOf
, wraps input actions to Cffu byrunAsync(Runnable)
.mRunAnySuccessAsync
(Executor executor, Runnable... actions) Shortcut to methodanySuccessOf
, wraps input actions to Cffu byrunAsync(Runnable, Executor)
.Shortcut to methodallOf
, wraps input actions to Cffu byrunAsync(Runnable)
.Shortcut to methodallOf
, wraps input actions to Cffu byrunAsync(Runnable, Executor)
.mRunFailFastAsync
(Runnable... actions) Shortcut to methodallFailFastOf
, wraps input actions to Cffu byrunAsync(Runnable)
.mRunFailFastAsync
(Executor executor, Runnable... actions) Shortcut to methodallFailFastOf
, wraps input actions to Cffu byrunAsync(Runnable, Executor)
.mSupplyAllSuccessAsync
(Executor executor, T valueIfFailed, Supplier<? extends T>... suppliers) Shortcut to methodallSuccessResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.mSupplyAllSuccessAsync
(T valueIfFailed, Supplier<? extends T>... suppliers) Shortcut to methodallSuccessResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.mSupplyAllSuccessTupleAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyAllSuccessAsync(Executor, Object, Supplier[])
withnull
valueIfFailed.mSupplyAllSuccessTupleAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyAllSuccessAsync(Executor, Object, Supplier[])
withnull
valueIfFailed.mSupplyAllSuccessTupleAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyAllSuccessAsync(Executor, Object, Supplier[])
withnull
valueIfFailed.mSupplyAllSuccessTupleAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyAllSuccessAsync(Executor, Object, Supplier[])
withnull
valueIfFailed.mSupplyAllSuccessTupleAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyAllSuccessAsync(Object, Supplier[])
withnull
valueIfFailed.mSupplyAllSuccessTupleAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyAllSuccessAsync(Object, Supplier[])
withnull
valueIfFailed.mSupplyAllSuccessTupleAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyAllSuccessAsync(Object, Supplier[])
withnull
valueIfFailed.mSupplyAllSuccessTupleAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyAllSuccessAsync(Object, Supplier[])
withnull
valueIfFailed.final <T> Cffu
<T> mSupplyAnyAsync
(Executor executor, Supplier<? extends T>... suppliers) Shortcut to methodanySuccessOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.final <T> Cffu
<T> mSupplyAnyAsync
(Supplier<? extends T>... suppliers) Shortcut to methodanyOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.final <T> Cffu
<T> mSupplyAnySuccessAsync
(Executor executor, Supplier<? extends T>... suppliers) Shortcut to methodanySuccessOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.final <T> Cffu
<T> mSupplyAnySuccessAsync
(Supplier<? extends T>... suppliers) Shortcut to methodanySuccessOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.mSupplyAsync
(Executor executor, Supplier<? extends T>... suppliers) Shortcut to methodallResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.mSupplyAsync
(Supplier<? extends T>... suppliers) Shortcut to methodallResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.mSupplyFailFastAsync
(Executor executor, Supplier<? extends T>... suppliers) Shortcut to methodallResultsFailFastOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.mSupplyFailFastAsync
(Supplier<? extends T>... suppliers) Shortcut to methodallResultsFailFastOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.mSupplyMostSuccessAsync
(Executor executor, T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier<? extends T>... suppliers) Shortcut to methodmostSuccessResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.mSupplyMostSuccessAsync
(T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier<? extends T>... suppliers) Shortcut to methodmostSuccessResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.mSupplyMostSuccessTupleAsync
(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyMostSuccessAsync(Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.mSupplyMostSuccessTupleAsync
(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyMostSuccessAsync(Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.mSupplyMostSuccessTupleAsync
(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyMostSuccessAsync(Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.mSupplyMostSuccessTupleAsync
(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyMostSuccessAsync(Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.mSupplyMostSuccessTupleAsync
(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.mSupplyMostSuccessTupleAsync
(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.mSupplyMostSuccessTupleAsync
(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.mSupplyMostSuccessTupleAsync
(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.mSupplyTupleAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
.mSupplyTupleAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
.mSupplyTupleAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
.mSupplyTupleAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
.mSupplyTupleAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyAsync(Supplier[])
.mSupplyTupleAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyAsync(Supplier[])
.mSupplyTupleAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyAsync(Supplier[])
.mSupplyTupleAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyAsync(Supplier[])
.mSupplyTupleFailFastAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
.mSupplyTupleFailFastAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
.mSupplyTupleFailFastAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
.mSupplyTupleFailFastAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
.mSupplyTupleFailFastAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyFailFastAsync(Supplier[])
.mSupplyTupleFailFastAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyFailFastAsync(Supplier[])
.mSupplyTupleFailFastAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyFailFastAsync(Supplier[])
.mSupplyTupleFailFastAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyFailFastAsync(Supplier[])
.<T> Cffu
<T> Return an incomplete Cffu, equivalent toCompletableFuture()
constructor.Returns a new Cffu that is asynchronously completed by a task running in thedefaultExecutor()
after it runs the given action.Returns a new Cffu that is asynchronously completed by a task running in the given executor after it runs the given action.<T> Cffu
<T> supplyAsync
(Supplier<T> supplier) Returns a new Cffu that is asynchronously completed by a task running in thedefaultExecutor()
with the value obtained by calling the given Supplier.<T> Cffu
<T> supplyAsync
(Supplier<T> supplier, Executor executor) Returns a new Cffu that is asynchronously completed by a task running in the given executor with the value obtained by calling the given Supplier.<T> Cffu
<T> toCffu
(CompletionStage<T> stage) Returns a Cffu maintaining the same completion properties as the given stage and thisCffuFactory
config.final <T> Cffu<T>[]
toCffuArray
(CompletionStage<T>... stages) Converts inputCompletionStage
(includingCompletableFuture
) array element bytoCffu(CompletionStage)
.withDefaultExecutor
(Executor defaultExecutor) Returns a CffuFactory from this CffuFactory with the defaultExecutor.
-
Method Details
-
builder
Returns aCffuFactoryBuilder
withdefaultExecutor
setting.- See Also:
-
withDefaultExecutor
Returns a CffuFactory from this CffuFactory with the defaultExecutor. -
newIncompleteCffu
Return an incomplete Cffu, equivalent toCompletableFuture()
constructor.In general, you should not use this method in application code, prefer other factory methods.
- See Also:
-
supplyAsync
@CheckReturnValue(explanation="should use the returned Cffu; otherwise, prefer method `runAsync`") public <T> Cffu<T> supplyAsync(Supplier<T> supplier) Returns a new Cffu that is asynchronously completed by a task running in thedefaultExecutor()
with the value obtained by calling the given Supplier.- Type Parameters:
T
- the function's return type- Parameters:
supplier
- a function returning the value to be used to complete the returned Cffu
-
supplyAsync
@CheckReturnValue(explanation="should use the returned Cffu; otherwise, prefer method `runAsync`") public <T> Cffu<T> supplyAsync(Supplier<T> supplier, Executor executor) Returns a new Cffu that is asynchronously completed by a task running in the given executor with the value obtained by calling the given Supplier.- Type Parameters:
T
- the function's return type- Parameters:
supplier
- a function returning the value to be used to complete the returned Cffuexecutor
- the executor to use for asynchronous execution
-
runAsync
Returns a new Cffu that is asynchronously completed by a task running in thedefaultExecutor()
after it runs the given action.- Parameters:
action
- the action to run before completing the returned Cffu
-
runAsync
Returns a new Cffu that is asynchronously completed by a task running in the given executor after it runs the given action.- Parameters:
action
- the action to run before completing the returned Cffuexecutor
- the executor to use for asynchronous execution
-
mSupplyFailFastAsync
@SafeVarargs public final <T> Cffu<List<T>> mSupplyFailFastAsync(Supplier<? extends T>... suppliers) Shortcut to methodallResultsFailFastOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.See the
allResultsFailFastOf
documentation for the rules of result computation. -
mSupplyFailFastAsync
@SafeVarargs public final <T> Cffu<List<T>> mSupplyFailFastAsync(Executor executor, Supplier<? extends T>... suppliers) Shortcut to methodallResultsFailFastOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.See the
allResultsFailFastOf
documentation for the rules of result computation. -
mSupplyAllSuccessAsync
@SafeVarargs public final <T> Cffu<List<T>> mSupplyAllSuccessAsync(@Nullable T valueIfFailed, Supplier<? extends T>... suppliers) Shortcut to methodallSuccessResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.See the
allSuccessResultsOf
documentation for the rules of result computation. -
mSupplyAllSuccessAsync
@SafeVarargs public final <T> Cffu<List<T>> mSupplyAllSuccessAsync(Executor executor, @Nullable T valueIfFailed, Supplier<? extends T>... suppliers) Shortcut to methodallSuccessResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.See the
allSuccessResultsOf
documentation for the rules of result computation. -
mSupplyMostSuccessAsync
@SafeVarargs public final <T> Cffu<List<T>> mSupplyMostSuccessAsync(@Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier<? extends T>... suppliers) Shortcut to methodmostSuccessResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.See the
mostSuccessResultsOf
documentation for the rules of result computation. -
mSupplyMostSuccessAsync
@SafeVarargs public final <T> Cffu<List<T>> mSupplyMostSuccessAsync(Executor executor, @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier<? extends T>... suppliers) Shortcut to methodmostSuccessResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.See the
mostSuccessResultsOf
documentation for the rules of result computation. -
mSupplyAsync
Shortcut to methodallResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.See the
allResultsOf
documentation for the rules of result computation. -
mSupplyAsync
@SafeVarargs public final <T> Cffu<List<T>> mSupplyAsync(Executor executor, Supplier<? extends T>... suppliers) Shortcut to methodallResultsOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.See the
allResultsOf
documentation for the rules of result computation. -
mSupplyAnySuccessAsync
Shortcut to methodanySuccessOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.See the
anySuccessOf
documentation for the rules of result computation. -
mSupplyAnySuccessAsync
@SafeVarargs public final <T> Cffu<T> mSupplyAnySuccessAsync(Executor executor, Supplier<? extends T>... suppliers) Shortcut to methodanySuccessOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.See the
anySuccessOf
documentation for the rules of result computation. -
mSupplyAnyAsync
Shortcut to methodanyOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier)
.See the
anySuccessOf
documentation for the rules of result computation. -
mSupplyAnyAsync
@SafeVarargs public final <T> Cffu<T> mSupplyAnyAsync(Executor executor, Supplier<? extends T>... suppliers) Shortcut to methodanySuccessOf
, wraps input suppliers to Cffu bysupplyAsync(Supplier, Executor)
.See the
anyOf
documentation for the rules of result computation. -
mRunFailFastAsync
Shortcut to methodallFailFastOf
, wraps input actions to Cffu byrunAsync(Runnable)
.See the
allFailFastOf
documentation for the rules of result computation. -
mRunFailFastAsync
Shortcut to methodallFailFastOf
, wraps input actions to Cffu byrunAsync(Runnable, Executor)
.See the
allFailFastOf
documentation for the rules of result computation. -
mRunAsync
Shortcut to methodallOf
, wraps input actions to Cffu byrunAsync(Runnable)
.See the
allOf
documentation for the rules of result computation. -
mRunAsync
Shortcut to methodallOf
, wraps input actions to Cffu byrunAsync(Runnable, Executor)
.See the
allOf
documentation for the rules of result computation. -
mRunAnySuccessAsync
Shortcut to methodanySuccessOf
, wraps input actions to Cffu byrunAsync(Runnable)
.See the
anySuccessOf
documentation for the rules of result computation. -
mRunAnySuccessAsync
Shortcut to methodanySuccessOf
, wraps input actions to Cffu byrunAsync(Runnable, Executor)
.See the
anySuccessOf
documentation for the rules of result computation. -
mRunAnyAsync
Shortcut to methodanyOf
, wraps input actions to Cffu byrunAsync(Runnable)
.See the
anyOf
documentation for the rules of result computation. -
mRunAnyAsync
Shortcut to methodanyOf
, wraps input actions to Cffu byrunAsync(Runnable, Executor)
.See the
anyOf
documentation for the rules of result computation. -
mSupplyTupleFailFastAsync
public <T1,T2> Cffu<Tuple2<T1,T2>> mSupplyTupleFailFastAsync(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyFailFastAsync(Supplier[])
. -
mSupplyTupleFailFastAsync
public <T1,T2> Cffu<Tuple2<T1,T2>> mSupplyTupleFailFastAsync(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
. -
mSupplyTupleFailFastAsync
public <T1,T2, Cffu<Tuple3<T1,T3> T2, mSupplyTupleFailFastAsyncT3>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyFailFastAsync(Supplier[])
. -
mSupplyTupleFailFastAsync
public <T1,T2, Cffu<Tuple3<T1,T3> T2, mSupplyTupleFailFastAsyncT3>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
. -
mSupplyTupleFailFastAsync
public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, mSupplyTupleFailFastAsyncT3, T4>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyFailFastAsync(Supplier[])
. -
mSupplyTupleFailFastAsync
public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, mSupplyTupleFailFastAsyncT3, T4>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
. -
mSupplyTupleFailFastAsync
public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, mSupplyTupleFailFastAsyncT3, T4, T5>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyFailFastAsync(Supplier[])
. -
mSupplyTupleFailFastAsync
public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, mSupplyTupleFailFastAsyncT3, T4, T5>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
. -
mSupplyAllSuccessTupleAsync
public <T1,T2> Cffu<Tuple2<T1,T2>> mSupplyAllSuccessTupleAsync(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyAllSuccessAsync(Object, Supplier[])
withnull
valueIfFailed.If any of the provided suppliers fails, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyAllSuccessTupleAsync
public <T1,T2> Cffu<Tuple2<T1,T2>> mSupplyAllSuccessTupleAsync(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyAllSuccessAsync(Executor, Object, Supplier[])
withnull
valueIfFailed.If any of the provided suppliers fails, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyAllSuccessTupleAsync
public <T1,T2, Cffu<Tuple3<T1,T3> T2, mSupplyAllSuccessTupleAsyncT3>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyAllSuccessAsync(Object, Supplier[])
withnull
valueIfFailed.If any of the provided suppliers fails, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyAllSuccessTupleAsync
public <T1,T2, Cffu<Tuple3<T1,T3> T2, mSupplyAllSuccessTupleAsyncT3>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyAllSuccessAsync(Executor, Object, Supplier[])
withnull
valueIfFailed.If any of the provided suppliers fails, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyAllSuccessTupleAsync
public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, mSupplyAllSuccessTupleAsyncT3, T4>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyAllSuccessAsync(Object, Supplier[])
withnull
valueIfFailed.If any of the provided suppliers fails, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyAllSuccessTupleAsync
public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, mSupplyAllSuccessTupleAsyncT3, T4>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyAllSuccessAsync(Executor, Object, Supplier[])
withnull
valueIfFailed.If any of the provided suppliers fails, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyAllSuccessTupleAsync
public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, mSupplyAllSuccessTupleAsyncT3, T4, T5>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyAllSuccessAsync(Object, Supplier[])
withnull
valueIfFailed.If any of the provided suppliers fails, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyAllSuccessTupleAsync
public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, mSupplyAllSuccessTupleAsyncT3, T4, T5>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyAllSuccessAsync(Executor, Object, Supplier[])
withnull
valueIfFailed.If any of the provided suppliers fails, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyMostSuccessTupleAsync
public <T1,T2> Cffu<Tuple2<T1,T2>> mSupplyMostSuccessTupleAsync(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyMostSuccessAsync(Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.If any of the provided suppliers is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyMostSuccessTupleAsync
public <T1,T2> Cffu<Tuple2<T1,T2>> mSupplyMostSuccessTupleAsync(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.If any of the provided suppliers is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyMostSuccessTupleAsync
public <T1,T2, Cffu<Tuple3<T1,T3> T2, mSupplyMostSuccessTupleAsyncT3>> (long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyMostSuccessAsync(Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.If any of the provided suppliers is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyMostSuccessTupleAsync
public <T1,T2, Cffu<Tuple3<T1,T3> T2, mSupplyMostSuccessTupleAsyncT3>> (Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.If any of the provided suppliers is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyMostSuccessTupleAsync
public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, mSupplyMostSuccessTupleAsyncT3, T4>> (long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyMostSuccessAsync(Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.If any of the provided suppliers is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyMostSuccessTupleAsync
public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, mSupplyMostSuccessTupleAsyncT3, T4>> (Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.If any of the provided suppliers is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyMostSuccessTupleAsync
public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, mSupplyMostSuccessTupleAsyncT3, T4, T5>> (long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyMostSuccessAsync(Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.If any of the provided suppliers is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyMostSuccessTupleAsync
public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, mSupplyMostSuccessTupleAsyncT3, T4, T5>> (Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])
withnull
valueIfNotSuccess.If any of the provided suppliers is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mSupplyTupleAsync
public <T1,T2> Cffu<Tuple2<T1,T2>> mSupplyTupleAsync(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyAsync(Supplier[])
. -
mSupplyTupleAsync
public <T1,T2> Cffu<Tuple2<T1,T2>> mSupplyTupleAsync(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
. -
mSupplyTupleAsync
public <T1,T2, Cffu<Tuple3<T1,T3> T2, mSupplyTupleAsyncT3>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyAsync(Supplier[])
. -
mSupplyTupleAsync
public <T1,T2, Cffu<Tuple3<T1,T3> T2, mSupplyTupleAsyncT3>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
. -
mSupplyTupleAsync
public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, mSupplyTupleAsyncT3, T4>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyAsync(Supplier[])
. -
mSupplyTupleAsync
public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, mSupplyTupleAsyncT3, T4>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
. -
mSupplyTupleAsync
public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, mSupplyTupleAsyncT3, T4, T5>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyAsync(Supplier[])
. -
mSupplyTupleAsync
public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, mSupplyTupleAsyncT3, T4, T5>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Tuple variant ofmSupplyFailFastAsync(Executor, Supplier[])
. -
allResultsFailFastOf
@Contract(pure=true) @SafeVarargs public final <T> Cffu<List<T>> allResultsFailFastOf(CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed normally with a list containing the successful results of all given stages when all the given stages complete normally; If any of the given stages complete exceptionally, then the returned Cffu also does so, WITHOUT waiting other incomplete given stages, with a CompletionException holding this exception as its cause. If no stages are provided, returns a Cffu completed with the value empty list.The list of results is in the same order as the input list.
This method is the same as
allResultsOf
method except for the fail-fast behavior.- Throws:
NullPointerException
- if the cfs param or any of its elements arenull
- See Also:
-
allSuccessResultsOf
@Contract(pure=true) @SafeVarargs public final <T> Cffu<List<T>> allSuccessResultsOf(@Nullable T valueIfFailed, CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed normally with a list containing the successful results of all given stages when all the given stages complete; The list of results is in the same order as the input list, and if any of given stages complete exceptionally, their corresponding position will containvalueIfFailed
(which is indistinguishable from the stage having a successful value ofvalueIfFailed
). If no stages are provided, returns a Cffu completed with the value empty list.The list of results is in the same order as the input list.
This method differs from
allResultsFailFastOf
method in that it's tolerant of failed stages for any of the items, representing them asvalueIfFailed
in the result list.- Parameters:
valueIfFailed
- the value used as result if the input stage completed exceptionally- Throws:
NullPointerException
- if the cfs param or any of its elements isnull
- See Also:
-
mostSuccessResultsOf
@Contract(pure=true) @SafeVarargs public final <T> Cffu<List<T>> mostSuccessResultsOf(@Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed normally with a list containing the successful results of the given stages before the given timeout (aka as many results as possible in the given time); The list of results is in the same order as the input list, and if any of given stages complete exceptionally or are incomplete, their corresponding positions will containvalueIfNotSuccess
(which is indistinguishable from the stage having a successful value ofvalueIfNotSuccess
). If no stages are provided, returns a Cffu completed with the value empty list.The list of results is in the same order as the input list.
This method differs from
allResultsFailFastOf
method in that it's tolerant of failed or incomplete stages for any of the items, representing them asvalueIfNotSuccess
in the result list.- Parameters:
valueIfNotSuccess
- the value used as result if the input stage not completed normallytimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Throws:
NullPointerException
- if the cfs param or any of its elements arenull
- See Also:
-
allResultsOf
@Contract(pure=true) @SafeVarargs public final <T> Cffu<List<T>> allResultsOf(CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed normally with a list containing the successful results of all given stages when all the given stages complete; If any of the given stages complete exceptionally, then the returned Cffu also does so, with a CompletionException holding this exception as its cause. If no stages are provided, returns a Cffu completed with the value empty list.The list of results is in the same order as the input list.
Comparing the waiting-all-complete behavior of this method, the fail-fast behavior of
allResultsFailFastOf
method is more responsive to user and generally more desired in the application.This method is the same as
allOf
method, except that the returned Cffu contains the results of the given stages.- Throws:
NullPointerException
- if the cfs param or any of its elements arenull
-
allFailFastOf
Returns a new Cffu that is completed normally when all the given stages complete normally; If any of the given stages complete exceptionally, then the returned Cffu also does so, WITHOUT waiting other incomplete given stages, with a CompletionException holding this exception as its cause. If no stages are provided, returns a Cffu completed with the valuenull
.The successful results, if any, of the given stages are not reflected in the returned Cffu (
Cffu<Void>
), but may be obtained by inspecting them individually; Or using below methods reflected results in the returned Cffu which are more convenient, safer and best-practice of concurrency:allResultsFailFastOf
,allTupleFailFastOf
allSuccessResultsOf
,allSuccessTupleOf
mostSuccessResultsOf
,mostSuccessTupleOf
allResultsOf
,allTupleOf
This method is the same as
allOf
method except for the fail-fast behavior.- Throws:
NullPointerException
- if the cfs param or any of its elements arenull
- See Also:
-
allOf
@CheckReturnValue(explanation="should use the returned Cffu; forget to call its `join()` method?") @Contract(pure=true) public Cffu<Void> allOf(CompletionStage<?>... cfs) Returns a new Cffu that is completed when all the given stages complete; If any of the given stages complete exceptionally, then the returned Cffu also does so, with a CompletionException holding this exception as its cause. If no stages are provided, returns a Cffu completed with the valuenull
.The successful results, if any, of the given stages are not reflected in the returned Cffu (
Cffu<Void>
), but may be obtained by inspecting them individually; Or using below methods reflected results in the returned Cffu which are more convenient, safer and best-practice of concurrency:allResultsOf
,allTupleOf
allResultsFailFastOf
,allTupleFailFastOf
allSuccessResultsOf
,allSuccessTupleOf
mostSuccessResultsOf
,mostSuccessTupleOf
Among the applications of this method is to await completion of a set of independent stages before continuing a program, as in:
cffuFactory.allOf(c1, c2, c3).join();
.- Throws:
NullPointerException
- if the cfs param or any of its elements arenull
- See Also:
-
anySuccessOf
Returns a new Cffu that completed normally when any of the given stages complete normally, with the same result; Otherwise, when all the given stages complete exceptionally, the returned Cffu also does so, with a CompletionException holding an exception from any of the given stages as its cause. If no stages are provided, returns a new Cffu that is already completed exceptionally with aNoCfsProvidedException
.This method differs from
anyOf
method in that this method is any-success instead of the any-complete behavior of methodanyOf
.- Throws:
NullPointerException
- if the cfs param or any of its elements arenull
-
anyOf
@Contract(pure=true) @SafeVarargs public final <T> Cffu<T> anyOf(CompletionStage<? extends T>... cfs) Returns a new Cffu that is completed with the same successful result or exception of any of the given stages when one stage completes. If no stages are provided, returns an incomplete Cffu.Comparing the any-complete behavior of this method, the any-success behavior of method
anySuccessOf
is more responsive to user and generally more desired in the application.- Throws:
NullPointerException
- if the cfs param or any of its elements arenull
-
allTupleFailFastOf
@Contract(pure=true) public <T1,T2> Cffu<Tuple2<T1,T2>> allTupleFailFastOf(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Tuple variant ofallResultsFailFastOf(CompletionStage[])
. -
allTupleFailFastOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple3<T1,T3> T2, allTupleFailFastOfT3>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Tuple variant ofallResultsFailFastOf(CompletionStage[])
. -
allTupleFailFastOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, allTupleFailFastOfT3, T4>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Tuple variant ofallResultsFailFastOf(CompletionStage[])
. -
allTupleFailFastOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, allTupleFailFastOfT3, T4, T5>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Tuple variant ofallResultsFailFastOf(CompletionStage[])
. -
allSuccessTupleOf
@Contract(pure=true) public <T1,T2> Cffu<Tuple2<T1,T2>> allSuccessTupleOf(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Tuple variant ofallSuccessResultsOf(Object, CompletionStage[])
withnull
valueIfFailed.If any of the provided stages fails, its corresponding position will contain
null
(which is indistinguishable from the stage having a successful value ofnull
). -
allSuccessTupleOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple3<T1,T3> T2, allSuccessTupleOfT3>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Tuple variant ofallSuccessResultsOf(Object, CompletionStage[])
withnull
valueIfFailed.If any of the provided stages fails, its corresponding position will contain
null
(which is indistinguishable from the stage having a successful value ofnull
). -
allSuccessTupleOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, allSuccessTupleOfT3, T4>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Tuple variant ofallSuccessResultsOf(Object, CompletionStage[])
withnull
valueIfFailed.If any of the provided stages fails, its corresponding position will contain
null
(which is indistinguishable from the stage having a successful value ofnull
). -
allSuccessTupleOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, allSuccessTupleOfT3, T4, T5>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Tuple variant ofallSuccessResultsOf(Object, CompletionStage[])
withnull
valueIfFailed.If any of the provided stages fails, its corresponding position will contain
null
(which is indistinguishable from the stage having a successful value ofnull
). -
mostSuccessTupleOf
@Contract(pure=true) public <T1,T2> Cffu<Tuple2<T1,T2>> mostSuccessTupleOf(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Tuple variant ofmostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])
withnull
valueIfNotSuccess.If any of the provided stages is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mostSuccessTupleOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple3<T1,T3> T2, mostSuccessTupleOfT3>> (long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Tuple variant ofmostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])
withnull
valueIfNotSuccess.If any of the provided stages is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mostSuccessTupleOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, mostSuccessTupleOfT3, T4>> (long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Tuple variant ofmostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])
withnull
valueIfNotSuccess.If any of the provided stages is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
mostSuccessTupleOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, mostSuccessTupleOfT3, T4, T5>> (long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Tuple variant ofmostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])
withnull
valueIfNotSuccess.If any of the provided stages is not completed normally, its corresponding position will contain
null
(which is indistinguishable from the supplier having a successful value ofnull
). -
allTupleOf
@Contract(pure=true) public <T1,T2> Cffu<Tuple2<T1,T2>> allTupleOf(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Tuple variant ofallResultsOf(CompletionStage[])
. -
allTupleOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple3<T1,T3> T2, allTupleOfT3>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Tuple variant ofallResultsOf(CompletionStage[])
. -
allTupleOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple4<T1,T3, T4> T2, allTupleOfT3, T4>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Tuple variant ofallResultsOf(CompletionStage[])
. -
allTupleOf
@Contract(pure=true) public <T1,T2, Cffu<Tuple5<T1,T3, T4, T5> T2, allTupleOfT3, T4, T5>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Tuple variant ofallResultsOf(CompletionStage[])
. -
completedFuture
Returns a new Cffu that is already completed with the given value.- Type Parameters:
T
- the type of the value- Parameters:
value
- the value- Returns:
- the completed Cffu
-
completedStage
Returns a new CompletionStage that is already completed with the given value and supports only those methods in interfaceCompletionStage
.CAUTION: if run on old Java 8 (which does not support *minimal* CompletionStage), this method just returns a *normal* Cffu instance which is NOT a *minimal* CompletionStage.
- Type Parameters:
T
- the type of the value- Parameters:
value
- the value- Returns:
- the completed CompletionStage
-
failedFuture
Returns a new Cffu that is already completed exceptionally with the given exception.- Type Parameters:
T
- the type of the value- Parameters:
ex
- the exception- Returns:
- the exceptionally completed Cffu
-
failedStage
Returns a new CompletionStage that is already completed exceptionally with the given exception and supports only those methods in interfaceCompletionStage
.CAUTION: if run on old Java 8 (which does not support *minimal* CompletionStage), this method just returns a *normal* Cffu instance which is NOT a *minimal* CompletionStage.
- Type Parameters:
T
- the type of the value- Parameters:
ex
- the exception- Returns:
- the exceptionally completed CompletionStage
-
toCffu
Returns a Cffu maintaining the same completion properties as the given stage and thisCffuFactory
config. If the given stage is already a Cffu and have the thisCffuFactory
, this method may return the given stage.- Throws:
NullPointerException
- if the given stage is null- See Also:
-
toCffuArray
@Contract(pure=true) @SafeVarargs public final <T> Cffu<T>[] toCffuArray(CompletionStage<T>... stages) Converts inputCompletionStage
(includingCompletableFuture
) array element bytoCffu(CompletionStage)
.- Throws:
NullPointerException
- if the stages param or any of its elements arenull
- See Also:
-
delayedExecutor
Returns a new Executor that submits a task to the default executor after the given delay (or no delay if non-positive). Each delay commences upon invocation of the returned executor'sexecute
method.- Parameters:
delay
- how long to delay, in units ofunit
unit
- aTimeUnit
determining how to interpret thedelay
parameter- Returns:
- the new delayed executor
-
delayedExecutor
Returns a new Executor that submits a task to the given base executor after the given delay (or no delay if non-positive). Each delay commences upon invocation of the returned executor'sexecute
method.- Parameters:
delay
- how long to delay, in units ofunit
unit
- aTimeUnit
determining how to interpret thedelay
parameterexecutor
- the base executor- Returns:
- the new delayed executor
-
cffuListToArray
Convert Cffu list to Cffu array.- See Also:
-
defaultExecutor
Returns the default Executor used for async methods that do not specify an Executor. Configured bybuilder(Executor)
.- Returns:
- the default executor
- See Also:
-
forbidObtrudeMethods
ReturnsforbidObtrudeMethods
or not.- See Also:
-