From 4587d0ab33ed6f302ff8cdf873b2f5dbf59c4a2e Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Sat, 29 Jun 2024 19:50:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20rename=20`all*OfFastFail`=20methods?= =?UTF-8?q?=20to=20`all*FastFailOf`,=20consistent=20with=20other=20methods?= =?UTF-8?q?=20=F0=9F=94=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +-- .../src/main/java/io/foldright/cffu/Cffu.java | 31 +++++++-- .../java/io/foldright/cffu/CffuFactory.java | 29 +++++++-- .../cffu/CompletableFutureUtils.java | 64 ++++++++++++------- .../io/foldright/cffu/CffuFactoryTest.java | 10 +-- .../cffu/CompletableFutureUtilsTest.java | 26 ++++---- .../demo/ConcurrencyStrategyDemo.java | 8 +-- .../foldright/cffu/kotlin/CffuExtensions.kt | 50 +++++++-------- .../kotlin/CompletableFutureExtensions.kt | 20 +++--- .../foldright/cffu/test/CffuExtensionsTest.kt | 24 +++---- .../test/CompletableFutureExtensionsTest.kt | 10 +-- 11 files changed, 166 insertions(+), 116 deletions(-) diff --git a/README.md b/README.md index 20fc908f..1e692fc9 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ - `allResultsOfFastFail`/`allResultsOf`方法:返回多个`CF`的结果,而不是无返回结果`Void`(`CompletableFuture#allOf()`) - `allTupleOfFastFail`/`allTupleOf`方法:返回多个`CF`不同类型的结果,而不是同一类型(`allResultsOf`) - 更高效灵活的并发执行策略,如 - - `allResultsOfFastFail`/`allOfFastFail`方法:有`CF`失败时快速返回,而不再等待所有`CF`运行完成(`allOf`) + - `allResultsOfFastFail`/`allFastFailOf`方法:有`CF`失败时快速返回,而不再等待所有`CF`运行完成(`allOf`) - `anySuccessOf`方法:返回首个成功的`CF`结果,而不是首个完成(但可能失败)的`CF`(`anyOf`) - `mostSuccessResultsOf`方法:返回指定时间内成功`CF`的结果,忽略失败或还没有运行完成的`CF`(使用缺省值) - 更安全的使用方式,如 @@ -434,7 +434,7 @@ public class DefaultExecutorSettingForCffu { > > `JavaScript Promise`提供了4个并发执行方法: > -> - [`Promise.all()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all):等待所有`Promise`运行成功,只要有一个失败就立即返回失败(对应`cffu`的`allOfFastFail`方法) +> - [`Promise.all()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all):等待所有`Promise`运行成功,只要有一个失败就立即返回失败(对应`cffu`的`allFastFailOf`方法) > - [`Promise.allSettled()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled):等待所有`Promise`运行完成,不管成功失败(对应`cffu`的`allOf`方法) > - [`Promise.any()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any):赛马模式,立即返回首个成功的`Promise`(对应`cffu`的`anySuccessOf`方法) > - [`Promise.race()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race):赛马模式,立即返回首个完成的`Promise`(对应`cffu`的`anyOf`方法) @@ -462,7 +462,7 @@ public class ConcurrencyStrategyDemo { final Cffu failed = cffuFactory.failedFuture(new RuntimeException("Bang!")); // Result type is Void! - Cffu cffuAll = cffuFactory.allOfFastFail(successAfterLongTime, failed); + Cffu cffuAll = cffuFactory.allFastFailOf(successAfterLongTime, failed); Cffu> fastFailed = cffuFactory.allResultsOfFastFail(successAfterLongTime, failed); // fast failed without waiting successAfterLongTime @@ -472,7 +472,7 @@ public class ConcurrencyStrategyDemo { System.out.println(anySuccessOf.get()); //////////////////////////////////////////////////////////////////////// - // or CompletableFutureUtils#allOfFastFail / allResultsOfFastFail + // or CompletableFutureUtils#allFastFailOf / allResultsOfFastFail // CompletableFutureUtils#anySuccessOf //////////////////////////////////////////////////////////////////////// final CompletableFuture successAfterLongTimeCf = CompletableFuture.supplyAsync(() -> { @@ -482,7 +482,7 @@ public class ConcurrencyStrategyDemo { final CompletableFuture failedCf = CompletableFutureUtils.failedFuture(new RuntimeException("Bang!")); // Result type is Void! - CompletableFuture cfAll = CompletableFutureUtils.allOfFastFail(successAfterLongTimeCf, failedCf); + CompletableFuture cfAll = CompletableFutureUtils.allFastFailOf(successAfterLongTimeCf, failedCf); CompletableFuture> fastFailedCf = CompletableFutureUtils.allResultsOfFastFail(successAfterLongTimeCf, failedCf); // fast failed without waiting successAfterLongTime diff --git a/cffu-core/src/main/java/io/foldright/cffu/Cffu.java b/cffu-core/src/main/java/io/foldright/cffu/Cffu.java index bc49c715..27a0e81d 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/Cffu.java +++ b/cffu-core/src/main/java/io/foldright/cffu/Cffu.java @@ -233,8 +233,8 @@ public final Cffu> thenMApplyFastFailAsync(Functionsame order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @param fns the functions to use to compute the values of the returned Cffu - * @param executor executor * @param the functions' return type * @return the new Cffu */ @@ -314,8 +314,9 @@ public final Cffu> thenMApplyAsync(Function. * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * - * @param fns the functions to use to compute the values of the returned Cffu - * @param the functions' return type + * @param executor the executor to use for asynchronous execution + * @param fns the functions to use to compute the values of the returned Cffu + * @param the functions' return type * @return the new Cffu */ @SafeVarargs @@ -340,7 +341,8 @@ public final Cffu thenMAcceptAsync(Consumer... actions) { * Returns a new Cffu that, when the given stage completes normally, * is executed using the given Executor, with the given stage's result as the argument to the given actions. * - * @param actions the actions to perform before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu */ @SafeVarargs @@ -365,7 +367,8 @@ public final Cffu thenMAcceptFastFailAsync(Consumer... actions) * Returns a new Cffu that, when the given stage completes normally, * is executed using the given Executor, with the given stage's result as the argument to the given actions. * - * @param actions the actions to perform before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu */ @SafeVarargs @@ -390,7 +393,8 @@ public Cffu thenMRunFastFailAsync(Runnable... actions) { * Returns a new Cffu that, when the given stage completes normally, * executes the given actions using the given Executor. * - * @param actions the actions to perform before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu * @see CompletableFuture#thenRunAsync(Runnable, Executor) */ @@ -414,7 +418,8 @@ public Cffu thenMRunAsync(Runnable... actions) { * Returns a new Cffu that, when the given stage completes normally, * executes the given actions using the given Executor. * - * @param actions the actions to perform before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu * @see CompletableFuture#thenRunAsync(Runnable, Executor) */ @@ -446,6 +451,7 @@ public Cffu> thenTupleMApplyFastFailAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyFastFailAsync( @@ -473,6 +479,7 @@ public Cffu> thenTupleMApplyFastFailAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyFastFailAsync( @@ -501,6 +508,7 @@ public Cffu> thenTupleMApplyFastFailAsyn * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyFastFailAsync( @@ -530,6 +538,7 @@ public Cffu> thenTupleMApplyFast * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyFastFailAsync( @@ -558,6 +567,7 @@ public Cffu> thenTupleMApplyMostSuccessAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyMostSuccessAsync( @@ -586,6 +596,7 @@ public Cffu> thenTupleMApplyMostSuccessAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyMostSuccessAsync( @@ -615,6 +626,7 @@ public Cffu> thenTupleMApplyMostSuccessA * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyMostSuccessAsync( @@ -645,6 +657,7 @@ public Cffu> thenTupleMApplyMost * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyMostSuccessAsync( @@ -673,6 +686,7 @@ public Cffu> thenTupleMApplyAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyAsync( @@ -700,6 +714,7 @@ public Cffu> thenTupleMApplyAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyAsync( @@ -728,6 +743,7 @@ public Cffu> thenTupleMApplyAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyAsync( @@ -757,6 +773,7 @@ public Cffu> thenTupleMApplyAsyn * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyAsync( diff --git a/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java b/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java index 07026830..c1ff72bc 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java @@ -173,6 +173,7 @@ public final Cffu> mSupplyFastFailAsync(Supplier... sup * with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @param suppliers the suppliers returning the value to be used to complete the returned Cffu * @param the suppliers' return type * @return the new Cffu @@ -217,6 +218,7 @@ public final Cffu> mSupplyMostSuccessAsync( * Otherwise the given valueIfNotSuccess. * * @param valueIfNotSuccess the value to return if not completed successfully + * @param executor the executor to use for asynchronous execution * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @param suppliers the suppliers returning the value to be used to complete the returned Cffu @@ -252,6 +254,7 @@ public final Cffu> mSupplyAsync(Supplier... suppliers) * with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @param suppliers the suppliers returning the value to be used to complete the returned Cffu * @param the suppliers' return type * @return the new Cffu @@ -270,7 +273,7 @@ public final Cffu> mSupplyAsync( * * @param actions the actions to run before completing the returned Cffu * @return the new Cffu - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) */ public Cffu mRunFastFailAsync(Runnable... actions) { return mRunFastFailAsync(defaultExecutor, actions); @@ -280,9 +283,10 @@ public Cffu mRunFastFailAsync(Runnable... actions) { * Returns a new Cffu that is asynchronously completed by tasks running in the given Executor * after runs the given actions. * - * @param actions the actions to run before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to run before completing the returned Cffu * @return the new Cffu - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) */ public Cffu mRunFastFailAsync(Executor executor, Runnable... actions) { return create(CompletableFutureUtils.mRunFastFailAsync(executor, actions)); @@ -305,7 +309,8 @@ public Cffu mRunAsync(Runnable... actions) { * Returns a new Cffu that is asynchronously completed by tasks running in the given Executor * after runs the given actions. * - * @param actions the actions to run before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to run before completing the returned Cffu * @return the new Cffu * @see #allOf(CompletionStage[]) */ @@ -336,6 +341,7 @@ public Cffu> tupleMSupplyFastFailAsync( * by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOfFastFail(CompletionStage[]) */ @@ -362,6 +368,7 @@ public Cffu> tupleMSupplyFastFailAsync( * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOfFastFail(CompletionStage[]) */ @@ -389,6 +396,7 @@ public Cffu> tupleMSupplyFastFailAsync( * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOfFastFail(CompletionStage[]) */ @@ -417,6 +425,7 @@ public Cffu> tupleMSupplyFastFai * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOfFastFail(CompletionStage[]) */ @@ -443,6 +452,7 @@ public Cffu> tupleMSupplyMostSuccessAsync( * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> tupleMSupplyMostSuccessAsync( @@ -469,6 +479,7 @@ public Cffu> tupleMSupplyMostSuccessAsync( * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> tupleMSupplyMostSuccessAsync( @@ -496,6 +507,7 @@ public Cffu> tupleMSupplyMostSuccessAsyn * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> tupleMSupplyMostSuccessAsync( @@ -523,6 +535,7 @@ public Cffu> tupleMSupplyMostSuc * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> tupleMSupplyMostSuccessAsync( @@ -551,6 +564,7 @@ public Cffu> tupleMSupplyAsync( * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOf(CompletionStage[]) */ @@ -577,6 +591,7 @@ public Cffu> tupleMSupplyAsync( * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOf(CompletionStage[]) */ @@ -605,6 +620,7 @@ public Cffu> tupleMSupplyAsync( * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOf(CompletionStage[]) */ @@ -633,6 +649,7 @@ public Cffu> tupleMSupplyAsync( * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOf(CompletionStage[]) */ @@ -736,8 +753,8 @@ public final Cffu> allResultsOf(CompletionStage... cfs) * @throws NullPointerException if the array or any of its elements are {@code null} */ @Contract(pure = true) - public Cffu allOfFastFail(CompletionStage... cfs) { - return create(CompletableFutureUtils.allOfFastFail(cfs)); + public Cffu allFastFailOf(CompletionStage... cfs) { + return create(CompletableFutureUtils.allFastFailOf(cfs)); } /** diff --git a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java index 16d334a0..e490a871 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -191,7 +191,7 @@ private static CompletableFuture[] wrapSuppliers( * * @param actions the actions to run before completing the returned CompletableFuture * @return the new CompletableFuture - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) * @see CompletableFuture#runAsync(Runnable) */ public static CompletableFuture mRunFastFailAsync(Runnable... actions) { @@ -205,14 +205,14 @@ public static CompletableFuture mRunFastFailAsync(Runnable... actions) { * @param executor the executor to use for asynchronous execution * @param actions the actions to run before completing the returned CompletableFuture * @return the new CompletableFuture - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) * @see CompletableFuture#runAsync(Runnable, Executor) */ public static CompletableFuture mRunFastFailAsync(Executor executor, Runnable... actions) { requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("action", actions); - return allOfFastFail(wrapRunnables(executor, actions)); + return allFastFailOf(wrapRunnables(executor, actions)); } /** @@ -402,7 +402,7 @@ private static CompletableFuture allTupleOf0(boolean fastFail, Completion final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); final CompletableFuture resultSetter; - if (fastFail) resultSetter = allOfFastFail(resultSetterCfs); + if (fastFail) resultSetter = allFastFailOf(resultSetterCfs); else resultSetter = CompletableFuture.allOf(resultSetterCfs); return resultSetter.thenApply(unused -> tupleOf0(result)); @@ -448,8 +448,9 @@ public static CompletableFuture> tupleMSupplyMostSuccess * If the given supplier is successful in the given time, the return result is the completed value; * Otherwise the given valueIfNotSuccess. * - * @param timeout how long to wait in units of {@code unit} - * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executor the executor to use for asynchronous execution + * @param timeout how long to wait in units of {@code unit} + * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return the new CompletableFuture */ public static CompletableFuture> tupleMSupplyMostSuccessAsync( @@ -491,8 +492,9 @@ public static CompletableFuture> tupleMSupplyMos * If the given supplier is successful in the given time, the return result is the completed value; * Otherwise the given valueIfNotSuccess. * - * @param timeout how long to wait in units of {@code unit} - * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executor the executor to use for asynchronous execution + * @param timeout how long to wait in units of {@code unit} + * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return the new CompletableFuture */ public static CompletableFuture> tupleMSupplyMostSuccessAsync( @@ -534,8 +536,9 @@ public static CompletableFuture> tupleMS * If the given supplier is successful in the given time, the return result is the completed value; * Otherwise the given valueIfNotSuccess. * - * @param timeout how long to wait in units of {@code unit} - * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executor the executor to use for asynchronous execution + * @param timeout how long to wait in units of {@code unit} + * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return the new CompletableFuture */ public static CompletableFuture> tupleMSupplyMostSuccessAsync( @@ -578,8 +581,9 @@ public static CompletableFuture> * If the given supplier is successful in the given time, the return result is the completed value; * Otherwise the given valueIfNotSuccess. * - * @param timeout how long to wait in units of {@code unit} - * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executor the executor to use for asynchronous execution + * @param timeout how long to wait in units of {@code unit} + * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return the new CompletableFuture */ public static CompletableFuture> tupleMSupplyMostSuccessAsync( @@ -640,6 +644,7 @@ public static CompletableFuture> tupleMSupplyAsync( * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture * @see #allResultsOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) @@ -672,6 +677,7 @@ public static CompletableFuture> tupleMSupplyAsy * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture * @see #allResultsOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) @@ -706,6 +712,7 @@ public static CompletableFuture> tupleMS * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture * @see #allResultsOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) @@ -740,6 +747,7 @@ public static CompletableFuture> * by tasks running in the given Executor with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture * @see #allResultsOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) @@ -915,7 +923,7 @@ public static CompletableFuture> allResultsOf(CompletionStage allOfFastFail(CompletionStage... cfs) { + public static CompletableFuture allFastFailOf(CompletionStage... cfs) { requireCfsAndEleNonNull(cfs); final int len = cfs.length; if (len == 0) return completedFuture(null); @@ -1597,8 +1605,8 @@ public static CompletableFuture> thenMApplyFastFailAsync( * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * - * @param fns the functions to use to compute the values of the returned CompletableFuture * @param executor the executor to use for asynchronous execution + * @param fns the functions to use to compute the values of the returned CompletableFuture * @param the functions' return type * @return the new CompletableFuture */ @@ -1779,7 +1787,7 @@ public static CompletableFuture thenMAcceptFastFailAsync( requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("action", actions); - return cfThis.thenCompose(v -> allOfFastFail(wrapConsumers(executor, v, actions))); + return cfThis.thenCompose(v -> allFastFailOf(wrapConsumers(executor, v, actions))); } private static CompletableFuture[] wrapConsumers(Executor executor, T v, Consumer[] actions) { @@ -1799,7 +1807,7 @@ private static CompletableFuture[] wrapConsumers(Executor executor, T * @param actions the actions to perform before completing the returned CompletableFuture * @return the new CompletableFuture * @see CompletableFuture#thenRunAsync(Runnable) - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) */ public static CompletableFuture thenMRunFastFailAsync(CompletableFuture cfThis, Runnable... actions) { return thenMRunFastFailAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, actions); @@ -1813,7 +1821,7 @@ public static CompletableFuture thenMRunFastFailAsync(CompletableFuture * @param actions the actions to perform before completing the returned CompletableFuture * @return the new CompletableFuture * @see CompletableFuture#thenRunAsync(Runnable, Executor) - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) */ public static CompletableFuture thenMRunFastFailAsync( CompletableFuture cfThis, Executor executor, Runnable... actions) { @@ -1821,7 +1829,7 @@ public static CompletableFuture thenMRunFastFailAsync( requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("action", actions); - return cfThis.thenCompose(unused -> allOfFastFail(wrapRunnables(executor, actions))); + return cfThis.thenCompose(unused -> allFastFailOf(wrapRunnables(executor, actions))); } /** @@ -1882,6 +1890,7 @@ public static CompletableFuture> thenTupleMApplyFastF * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( @@ -1915,6 +1924,7 @@ public static CompletableFuture> thenTupleMAp * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( @@ -1949,6 +1959,7 @@ public static CompletableFuture> then * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( @@ -1984,6 +1995,7 @@ public static CompletableFuturesame order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( @@ -2216,6 +2228,7 @@ public static CompletableFuture> thenTupleMApplyAsync * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( @@ -2249,6 +2262,7 @@ public static CompletableFuture> thenTupleMAp * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( @@ -2283,6 +2297,7 @@ public static CompletableFuture> then * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( @@ -2318,6 +2333,7 @@ public static CompletableFuturesame order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( @@ -2360,7 +2376,7 @@ public static CompletableFuture thenCombineFastFail( final Object[] result = new Object[css.length]; final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); - return allOfFastFail(resultSetterCfs).thenApply(unused -> fn.apply((T) result[0], (U) result[1])); + return allFastFailOf(resultSetterCfs).thenApply(unused -> fn.apply((T) result[0], (U) result[1])); } /** @@ -2402,7 +2418,7 @@ public static CompletableFuture thenCombineFastFailAsync( final Object[] result = new Object[css.length]; final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); - return allOfFastFail(resultSetterCfs) + return allFastFailOf(resultSetterCfs) .thenApplyAsync(unused -> fn.apply((T) result[0], (U) result[1]), executor); } @@ -2426,7 +2442,7 @@ public static CompletableFuture thenAcceptBothFastFail( final Object[] result = new Object[css.length]; final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); - return allOfFastFail(resultSetterCfs).thenRun(() -> action.accept((T) result[0], (U) result[1])); + return allFastFailOf(resultSetterCfs).thenRun(() -> action.accept((T) result[0], (U) result[1])); } /** @@ -2468,7 +2484,7 @@ public static CompletableFuture thenAcceptBothFastFailAsync( final Object[] result = new Object[css.length]; final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); - return allOfFastFail(resultSetterCfs).thenRunAsync(() -> action.accept((T) result[0], (U) result[1]), executor); + return allFastFailOf(resultSetterCfs).thenRunAsync(() -> action.accept((T) result[0], (U) result[1]), executor); } /** @@ -2485,7 +2501,7 @@ public static CompletableFuture runAfterBothFastFail( final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(action, "action is null"); - return allOfFastFail(css).thenRun(action); + return allFastFailOf(css).thenRun(action); } /** @@ -2519,7 +2535,7 @@ public static CompletableFuture runAfterBothFastFailAsync( requireNonNull(action, "action is null"); requireNonNull(executor, "executor is null"); - return allOfFastFail(css).thenRunAsync(action, executor); + return allFastFailOf(css).thenRunAsync(action, executor); } // endregion diff --git a/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java b/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java index d2d76671..8da2177f 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java @@ -209,13 +209,13 @@ void test_allOf_CompletableFuture() throws Exception { //////////////////////////////////////// - cffuFactory.allOfFastFail(completedFuture(n), completedFuture(anotherN)).get(); - cffuFactory.allOfFastFail(completedFuture(anotherN)).get(); + cffuFactory.allFastFailOf(completedFuture(n), completedFuture(anotherN)).get(); + cffuFactory.allFastFailOf(completedFuture(anotherN)).get(); - assertNull(cffuFactory.allOfFastFail().get()); + assertNull(cffuFactory.allFastFailOf().get()); - cffuFactory.allOfFastFail(cffuFactory.completedFuture(n), cffuFactory.completedFuture(anotherN)).get(); - cffuFactory.allOfFastFail(cffuFactory.completedFuture(anotherN)).get(); + cffuFactory.allFastFailOf(cffuFactory.completedFuture(n), cffuFactory.completedFuture(anotherN)).get(); + cffuFactory.allFastFailOf(cffuFactory.completedFuture(anotherN)).get(); } @Test diff --git a/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java b/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java index 7bec7fc2..eafcd97d 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java @@ -129,11 +129,11 @@ void test_allOf_methods__success__trivial_case() throws Exception { allOf(completedStage(n)), allOf(), - allOfFastFail(completedFuture(n), completedStage(n + 1), completedFuture(n + 2)), - allOfFastFail(completedStage(n), completedFuture(n + 1)), - allOfFastFail(completedFuture(n)), - allOfFastFail(completedStage(n)), - allOfFastFail() + allFastFailOf(completedFuture(n), completedStage(n + 1), completedFuture(n + 2)), + allFastFailOf(completedStage(n), completedFuture(n + 1)), + allFastFailOf(completedFuture(n)), + allFastFailOf(completedStage(n)), + allFastFailOf() ).forEach(f -> assertNull(f.join())); } @@ -261,14 +261,14 @@ void test_allOf__exceptionally() throws Exception { ).getCause()); //////////////////////////////////////////////////////////////////////////////// - // allOfFastFail + // allFastFailOf //////////////////////////////////////////////////////////////////////////////// // all failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - // allOfFastFail: the ex of first complete(in time) cf argument win. + // allFastFailOf: the ex of first complete(in time) cf argument win. // ❗dependent on the implementation behavior of `CF.allOf`️ - allOfFastFail( + allFastFailOf( failedFuture(rte), failedFuture(anotherRte), failedFuture(ex1), @@ -278,9 +278,9 @@ void test_allOf__exceptionally() throws Exception { // all failed - concurrent assertSame(anotherRte, assertThrowsExactly(ExecutionException.class, () -> - // allOfFastFail: the ex of first complete(in time) cf argument win, even subsequent cf failed early. + // allFastFailOf: the ex of first complete(in time) cf argument win, even subsequent cf failed early. // ❗dependent on the implementation behavior of `CF.allOf`️ - allOfFastFail( + allFastFailOf( CompletableFuture.supplyAsync(() -> { sleep(100); throw rte; @@ -293,7 +293,7 @@ void test_allOf__exceptionally() throws Exception { // success and failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allOfFastFail( + allFastFailOf( completedFuture(n), failedFuture(rte), completedFuture(s), @@ -303,7 +303,7 @@ void test_allOf__exceptionally() throws Exception { // failed/incomplete/failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allOfFastFail( + allFastFailOf( completedFuture(n), failedFuture(rte), createIncompleteFuture() @@ -312,7 +312,7 @@ void test_allOf__exceptionally() throws Exception { // incomplete fail incomplete assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allOfFastFail( + allFastFailOf( createIncompleteFuture(), failedFuture(rte), createIncompleteFuture() diff --git a/cffu-core/src/test/java/io/foldright/demo/ConcurrencyStrategyDemo.java b/cffu-core/src/test/java/io/foldright/demo/ConcurrencyStrategyDemo.java index 70b04cf0..857eccda 100644 --- a/cffu-core/src/test/java/io/foldright/demo/ConcurrencyStrategyDemo.java +++ b/cffu-core/src/test/java/io/foldright/demo/ConcurrencyStrategyDemo.java @@ -16,7 +16,7 @@ public class ConcurrencyStrategyDemo { public static void main(String[] args) throws Exception { //////////////////////////////////////////////////////////////////////// - // CffuFactory#allOfFastFail / allResultsOfFastFail + // CffuFactory#allFastFailOf / allResultsOfFastFail // CffuFactory#anySuccessOf //////////////////////////////////////////////////////////////////////// final Cffu successAfterLongTime = cffuFactory.supplyAsync(() -> { @@ -26,7 +26,7 @@ public static void main(String[] args) throws Exception { final Cffu failed = cffuFactory.failedFuture(new RuntimeException("Bang!")); // Result type is Void! - Cffu cffuAll = cffuFactory.allOfFastFail(successAfterLongTime, failed); + Cffu cffuAll = cffuFactory.allFastFailOf(successAfterLongTime, failed); Cffu> fastFailed = cffuFactory.allResultsOfFastFail(successAfterLongTime, failed); // fast failed without waiting successAfterLongTime @@ -36,7 +36,7 @@ public static void main(String[] args) throws Exception { System.out.println(anySuccessOf.get()); //////////////////////////////////////////////////////////////////////// - // or CompletableFutureUtils#allOfFastFail / allResultsOfFastFail + // or CompletableFutureUtils#allFastFailOf / allResultsOfFastFail // CompletableFutureUtils#anySuccessOf //////////////////////////////////////////////////////////////////////// final CompletableFuture successAfterLongTimeCf = CompletableFuture.supplyAsync(() -> { @@ -46,7 +46,7 @@ public static void main(String[] args) throws Exception { final CompletableFuture failedCf = CompletableFutureUtils.failedFuture(new RuntimeException("Bang!")); // Result type is Void! - CompletableFuture cfAll = CompletableFutureUtils.allOfFastFail(successAfterLongTimeCf, failedCf); + CompletableFuture cfAll = CompletableFutureUtils.allFastFailOf(successAfterLongTimeCf, failedCf); CompletableFuture> fastFailedCf = CompletableFutureUtils.allResultsOfFastFail(successAfterLongTimeCf, failedCf); // fast failed without waiting successAfterLongTime diff --git a/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt b/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt index fd90a15f..1b80bdf7 100644 --- a/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt +++ b/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt @@ -69,14 +69,14 @@ private const val ERROR_MSG_FOR_ARRAY = "no cffuFactory argument provided when t * with a CompletionException holding this exception as its cause. * If no Cffus are provided, returns a Cffu completed with the value empty list. * - * This method is the same as [allOfFastFailCffu], except the returned Cffu contains the results of input Cffus. + * This method is the same as [allFastFailOfCffu], except the returned Cffu contains the results of input Cffus. * * This method is the same as [CffuFactory.allResultsOfFastFail], providing this method is convenient for method chaining. * * If this collection is not empty, `cffuFactory` argument is optional, use the `cffuFactory` of the first cffu element. * If this collection is empty and no`cffuFactory` provided, throw [IllegalArgumentException]. * - * @see allOfFastFailCffu + * @see allFastFailOfCffu * @see CffuFactory.allResultsOfFastFail */ fun Collection>.allResultsOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cffu> { @@ -93,14 +93,14 @@ fun Collection>.allResultsOfFastFailCffu(cffuFactory: CffuFactor * with a CompletionException holding this exception as its cause. * If no Cffus are provided, returns a Cffu completed with the value empty list. * - * This method is the same as [allOfFastFailCffu], except the returned Cffu contains the results of input Cffus. + * This method is the same as [allFastFailOfCffu], except the returned Cffu contains the results of input Cffus. * * This method is the same as [CffuFactory.allResultsOfFastFail], providing this method is convenient for method chaining. * * If this array is not empty, `cffuFactory` argument is optional, use the `cffuFactory` of the first cffu element. * If this array is empty and no`cffuFactory` provided, throw [IllegalArgumentException]. * - * @see allOfFastFailCffu + * @see allFastFailOfCffu * @see CffuFactory.allResultsOfFastFail */ fun Array>.allResultsOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cffu> { @@ -117,11 +117,11 @@ fun Array>.allResultsOfFastFailCffu(cffuFactory: CffuFactory * with a CompletionException holding this exception as its cause. * If no stages are provided, returns a Cffu completed with the value empty list. * - * This method is the same as [allOfFastFailCffu], except the returned Cffu contains the results of input Cffus. + * This method is the same as [allFastFailOfCffu], except the returned Cffu contains the results of input Cffus. * * This method is the same as [CffuFactory.allResultsOfFastFail], providing this method is convenient for method chaining. * - * @see allOfFastFailCffu + * @see allFastFailOfCffu * @see CffuFactory.allResultsOfFastFail */ @JvmName("allResultsOfFastFailCffuCs") @@ -136,11 +136,11 @@ fun Collection>.allResultsOfFastFailCffu(cffuFactory: * with a CompletionException holding this exception as its cause. * If no stages are provided, returns a Cffu completed with the value empty list. * - * This method is the same as [allOfFastFailCffu], except the returned Cffu contains the results of input Cffus. + * This method is the same as [allFastFailOfCffu], except the returned Cffu contains the results of input Cffus. * * This method is the same as [CffuFactory.allResultsOfFastFail], providing this method is convenient for method chaining. * - * @see allOfFastFailCffu + * @see allFastFailOfCffu * @see CffuFactory.allResultsOfFastFail */ fun Array>.allResultsOfFastFailCffu(cffuFactory: CffuFactory): Cffu> = @@ -316,18 +316,18 @@ fun Array>.allResultsOfCffu(cffuFactory: CffuFact * with a CompletionException holding this exception as its cause. * If no Cffus are provided, returns a Cffu completed with the value `null`. * - * This method is the same as [CffuFactory.allOfFastFail], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * * If this collection is not empty, `cffuFactory` argument is optional, use the `cffuFactory` of the first cffu element. * If this collection is empty and no`cffuFactory` provided, throw [IllegalArgumentException]. * * @see allResultsOfFastFailCffu - * @see CffuFactory.allOfFastFail + * @see CffuFactory.allFastFailOf */ -fun Collection>.allOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cffu { +fun Collection>.allFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_COLL) - return factory.allOfFastFail(*toTypedArray()) + return factory.allFastFailOf(*toTypedArray()) } /** @@ -339,18 +339,18 @@ fun Collection>.allOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cf * with a CompletionException holding this exception as its cause. * If no Cffus are provided, returns a Cffu completed with the value `null`. * - * This method is the same as [CffuFactory.allOfFastFail], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * * If this array is not empty, `cffuFactory` argument is optional, use the `cffuFactory` of the first cffu element. * If this array is empty and no`cffuFactory` provided, throw [IllegalArgumentException]. * * @see allResultsOfFastFailCffu - * @see CffuFactory.allOfFastFail + * @see CffuFactory.allFastFailOf */ -fun Array>.allOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cffu { +fun Array>.allFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_ARRAY) - return factory.allOfFastFail(*this) + return factory.allFastFailOf(*this) } /** @@ -362,14 +362,14 @@ fun Array>.allOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cff * with a CompletionException holding this exception as its cause. * If no stages are provided, returns a Cffu completed with the value `null`. * - * This method is the same as [CffuFactory.allOfFastFail], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * * @see allResultsOfFastFailCffu - * @see CffuFactory.allOfFastFail + * @see CffuFactory.allFastFailOf */ -@JvmName("allOfFastFailCffuCs") -fun Collection>.allOfFastFailCffu(cffuFactory: CffuFactory): Cffu = - cffuFactory.allOfFastFail(*toTypedArray()) +@JvmName("allFastFailOfCffuCs") +fun Collection>.allFastFailOfCffu(cffuFactory: CffuFactory): Cffu = + cffuFactory.allFastFailOf(*toTypedArray()) /** * Returns a new Cffu that is successful when all the given stages success, @@ -380,13 +380,13 @@ fun Collection>.allOfFastFailCffu(cffuFactory: CffuFactory): * with a CompletionException holding this exception as its cause. * If no stages are provided, returns a Cffu completed with the value `null`. * - * This method is the same as [CffuFactory.allOfFastFail], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * * @see allResultsOfFastFailCffu - * @see CffuFactory.allOfFastFail + * @see CffuFactory.allFastFailOf */ -fun Array>.allOfFastFailCffu(cffuFactory: CffuFactory): Cffu = - cffuFactory.allOfFastFail(*this) +fun Array>.allFastFailOfCffu(cffuFactory: CffuFactory): Cffu = + cffuFactory.allFastFailOf(*this) /** * Returns a new Cffu that is completed when all the given Cffus complete. diff --git a/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt b/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt index ac1dda05..44b180d7 100644 --- a/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt +++ b/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt @@ -31,13 +31,13 @@ import java.util.function.Function * with a CompletionException holding this exception as its cause. * If no CompletableFutures are provided, returns a CompletableFuture completed with the value empty list. * - * This method is the same as [allOfFastFailCompletableFuture], + * This method is the same as [allFastFailOfCompletableFuture], * except the returned CompletableFuture contains the results of input CompletableFutures. * * This method is the same as [CompletableFutureUtils.allResultsOfFastFail], * providing this method is convenient for method chaining. * - * @see allOfFastFailCompletableFuture + * @see allFastFailOfCompletableFuture */ fun Collection>.allResultsOfFastFailCompletableFuture(): CompletableFuture> = CompletableFutureUtils.allResultsOfFastFail(*toTypedArray()) @@ -50,13 +50,13 @@ fun Collection>.allResultsOfFastFailCompletableFuture * with a CompletionException holding this exception as its cause. * If no CompletableFutures are provided, returns a CompletableFuture completed with the value empty list. * - * This method is the same as [allOfFastFailCompletableFuture], + * This method is the same as [allFastFailOfCompletableFuture], * except the returned CompletableFuture contains the results of input CompletableFutures. * * This method is the same as [CompletableFutureUtils.allResultsOfFastFail], * providing this method is convenient for method chaining. * - * @see allOfFastFailCompletableFuture + * @see allFastFailOfCompletableFuture */ fun Array>.allResultsOfFastFailCompletableFuture(): CompletableFuture> = CompletableFutureUtils.allResultsOfFastFail(*this) @@ -178,13 +178,13 @@ fun Array>.allResultsOfCompletableFuture(): Compl * * - [allResultsOfFastFailCompletableFuture] * - * This method is the same as [CompletableFutureUtils.allOfFastFail], + * This method is the same as [CompletableFutureUtils.allFastFailOf], * providing this method is convenient for method chaining. * * @see allResultsOfFastFailCompletableFuture */ -fun Collection>.allOfFastFailCompletableFuture(): CompletableFuture = - CompletableFutureUtils.allOfFastFail(*toTypedArray()) +fun Collection>.allFastFailOfCompletableFuture(): CompletableFuture = + CompletableFutureUtils.allFastFailOf(*toTypedArray()) /** * Returns a new CompletableFuture that is successful when all the given CompletableFutures success, @@ -199,13 +199,13 @@ fun Collection>.allOfFastFailCompletableFuture(): Completable * * - [allResultsOfFastFailCompletableFuture] * - * This method is the same as [CompletableFutureUtils.allOfFastFail], + * This method is the same as [CompletableFutureUtils.allFastFailOf], * providing this method is convenient for method chaining. * * @see allResultsOfFastFailCompletableFuture */ -fun Array>.allOfFastFailCompletableFuture(): CompletableFuture = - CompletableFutureUtils.allOfFastFail(*this) +fun Array>.allFastFailOfCompletableFuture(): CompletableFuture = + CompletableFutureUtils.allFastFailOf(*this) /** * Returns a new CompletableFuture that is completed when all the given stages complete. diff --git a/cffu-kotlin/src/test/java/io/foldright/cffu/test/CffuExtensionsTest.kt b/cffu-kotlin/src/test/java/io/foldright/cffu/test/CffuExtensionsTest.kt index 1d0b2499..fe685730 100644 --- a/cffu-kotlin/src/test/java/io/foldright/cffu/test/CffuExtensionsTest.kt +++ b/cffu-kotlin/src/test/java/io/foldright/cffu/test/CffuExtensionsTest.kt @@ -250,31 +250,31 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() listOf( testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu().await().shouldBeNull() + ).allFastFailOfCffu().await().shouldBeNull() setOf( testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() listOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() setOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() // Array @@ -282,19 +282,19 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() arrayOf( testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu().await().shouldBeNull() + ).allFastFailOfCffu().await().shouldBeNull() arrayOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() } test("mostSuccessResultsOfCffu") { @@ -598,10 +598,10 @@ class CffuExtensionsTest : FunSpec({ assertEmptyArray { emptyArray.allResultsOfFastFailCffu() } assertCffuFactoryForOptional(array.allResultsOfFastFailCffu()) - assertEmptyCollection { emptyList.allOfFastFailCffu() } - assertCffuFactoryForOptional(list.allOfFastFailCffu()) - assertEmptyArray { emptyArray.allOfFastFailCffu() } - assertCffuFactoryForOptional(array.allOfFastFailCffu()) + assertEmptyCollection { emptyList.allFastFailOfCffu() } + assertCffuFactoryForOptional(list.allFastFailOfCffu()) + assertEmptyArray { emptyArray.allFastFailOfCffu() } + assertCffuFactoryForOptional(array.allFastFailOfCffu()) assertEmptyCollection { emptyList.mostSuccessResultsOfCffu(4, 1, TimeUnit.MILLISECONDS) } assertCffuFactoryForOptional(list.mostSuccessResultsOfCffu(4, 1, TimeUnit.MILLISECONDS)) diff --git a/cffu-kotlin/src/test/java/io/foldright/cffu/test/CompletableFutureExtensionsTest.kt b/cffu-kotlin/src/test/java/io/foldright/cffu/test/CompletableFutureExtensionsTest.kt index f6b7a08b..14ccedca 100644 --- a/cffu-kotlin/src/test/java/io/foldright/cffu/test/CompletableFutureExtensionsTest.kt +++ b/cffu-kotlin/src/test/java/io/foldright/cffu/test/CompletableFutureExtensionsTest.kt @@ -95,21 +95,21 @@ class CompletableFutureExtensionsTest : FunSpec({ CompletableFuture.completedFuture(42), CompletableFuture.completedFuture("42"), CompletableFuture.completedFuture(42.0), - ).allOfFastFailCompletableFuture().await().shouldBeNull() - listOf>().allOfFastFailCompletableFuture().await().shouldBeNull() + ).allFastFailOfCompletableFuture().await().shouldBeNull() + listOf>().allFastFailOfCompletableFuture().await().shouldBeNull() setOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture("42"), CompletableFuture.completedFuture(42.0), - ).allOfFastFailCompletableFuture().await().shouldBeNull() + ).allFastFailOfCompletableFuture().await().shouldBeNull() arrayOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture("42"), CompletableFuture.completedFuture(42.0), - ).allOfFastFailCompletableFuture().await().shouldBeNull() - arrayOf>().allOfFastFailCompletableFuture().await().shouldBeNull() + ).allFastFailOfCompletableFuture().await().shouldBeNull() + arrayOf>().allFastFailOfCompletableFuture().await().shouldBeNull() } test("mostSuccessResultsOfCompletableFuture") {