From fc1761cb9dd024b586cec83c7c2a0c987168b71a Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Sat, 30 Nov 2024 18:24:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20adjust=20executor=20parameter=20pos?= =?UTF-8?q?ition=20with=20more=20consistent=20rule:=20=F0=9F=AA=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - first parameter(except CfThis) for vararg methods - `mSupplyAllSuccessAsync` - `mSupplyMostSuccessAsync` - `mostSuccessResultsOf` - `thenMApplyAllSuccessAsync` - `thenMApplyMostSuccessAsync` - last parameter for non-vararg methods - `cffuOrTimeout` - `cffuCompleteOnTimeout` --- .../src/main/java/io/foldright/cffu/Cffu.java | 48 +++---- .../java/io/foldright/cffu/CffuFactory.java | 14 +-- .../cffu/CompletableFutureUtils.java | 119 +++++++++--------- .../io/foldright/cffu/CffuFactoryTest.java | 4 +- .../test/java/io/foldright/cffu/CffuTest.java | 12 +- .../io/foldright/cffu/CheckExecutorTests.kt | 12 +- .../cffu/CheckMinStageRuntimeTypeTests.kt | 62 ++++----- .../cffu/CompletableFutureUtilsTest.java | 20 +-- .../foldright/cffu/kotlin/CffuExtensions.kt | 8 +- .../kotlin/CompletableFutureExtensions.kt | 20 +-- 10 files changed, 157 insertions(+), 162 deletions(-) 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 da241768..0817b89f 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/Cffu.java +++ b/cffu-core/src/main/java/io/foldright/cffu/Cffu.java @@ -247,7 +247,7 @@ public final Cffu> thenMApplyFailFastAsync(Executor executor, Functi @SafeVarargs public final Cffu> thenMApplyAllSuccessAsync( @Nullable U valueIfFailed, Function... fns) { - return thenMApplyAllSuccessAsync(valueIfFailed, fac.defaultExecutor(), fns); + return thenMApplyAllSuccessAsync(fac.defaultExecutor(), valueIfFailed, fns); } /** @@ -264,8 +264,8 @@ public final Cffu> thenMApplyAllSuccessAsync( */ @SafeVarargs public final Cffu> thenMApplyAllSuccessAsync( - @Nullable U valueIfFailed, Executor executor, Function... fns) { - return resetCf(CompletableFutureUtils.thenMApplyAllSuccessAsync(cf, valueIfFailed, executor, fns)); + Executor executor, @Nullable U valueIfFailed, Function... fns) { + return resetCf(CompletableFutureUtils.thenMApplyAllSuccessAsync(cf, executor, valueIfFailed, fns)); } /** @@ -278,7 +278,7 @@ public final Cffu> thenMApplyAllSuccessAsync( @SafeVarargs public final Cffu> thenMApplyMostSuccessAsync( @Nullable U valueIfNotSuccess, long timeout, TimeUnit unit, Function... fns) { - return thenMApplyMostSuccessAsync(valueIfNotSuccess, fac.defaultExecutor(), timeout, unit, fns); + return thenMApplyMostSuccessAsync(fac.defaultExecutor(), valueIfNotSuccess, timeout, unit, fns); } /** @@ -290,9 +290,9 @@ public final Cffu> thenMApplyMostSuccessAsync( */ @SafeVarargs public final Cffu> thenMApplyMostSuccessAsync( - @Nullable U valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, + Executor executor, @Nullable U valueIfNotSuccess, long timeout, TimeUnit unit, Function... fns) { - return resetCf(CompletableFutureUtils.thenMApplyMostSuccessAsync(cf, valueIfNotSuccess, executor, timeout, unit, fns)); + return resetCf(CompletableFutureUtils.thenMApplyMostSuccessAsync(cf, executor, valueIfNotSuccess, timeout, unit, fns)); } /** @@ -673,7 +673,7 @@ public Cffu> thenMApplyAllSuccessTupleAsync( } /** - * Tuple variance of {@link #thenMApplyAllSuccessAsync(Object, Executor, Function[])} with {@code null} valueIfFailed. + * Tuple variance of {@link #thenMApplyAllSuccessAsync(Executor, Object, Function[])} with {@code null} valueIfFailed. *

* If any of the provided functions fails, its corresponding position will contain {@code null} * (which is indistinguishable from the function having a successful value of {@code null}). @@ -696,7 +696,7 @@ public Cffu> thenMApplyAllSuccessTupleAsync( } /** - * Tuple variance of {@link #thenMApplyAllSuccessAsync(Object, Executor, Function[])} with {@code null} valueIfFailed. + * Tuple variance of {@link #thenMApplyAllSuccessAsync(Executor, Object, Function[])} with {@code null} valueIfFailed. *

* If any of the provided functions fails, its corresponding position will contain {@code null} * (which is indistinguishable from the function having a successful value of {@code null}). @@ -720,7 +720,7 @@ public Cffu> thenMApplyAllSuccessTupleAs } /** - * Tuple variance of {@link #thenMApplyAllSuccessAsync(Object, Executor, Function[])} with {@code null} valueIfFailed. + * Tuple variance of {@link #thenMApplyAllSuccessAsync(Executor, Object, Function[])} with {@code null} valueIfFailed. *

* If any of the provided functions fails, its corresponding position will contain {@code null} * (which is indistinguishable from the function having a successful value of {@code null}). @@ -745,7 +745,7 @@ public Cffu> thenMApplyAllSucces } /** - * Tuple variance of {@link #thenMApplyAllSuccessAsync(Object, Executor, Function[])} with {@code null} valueIfFailed. + * Tuple variance of {@link #thenMApplyAllSuccessAsync(Executor, Object, Function[])} with {@code null} valueIfFailed. *

* If any of the provided functions fails, its corresponding position will contain {@code null} * (which is indistinguishable from the function having a successful value of {@code null}). @@ -770,7 +770,7 @@ public Cffu> thenMApplyMostSuccessTupleAsync( } /** - * Tuple variance of {@link #thenMApplyMostSuccessAsync(Object, Executor, long, TimeUnit, Function[])} + * Tuple variance of {@link #thenMApplyMostSuccessAsync(Executor, Object, long, TimeUnit, Function[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} @@ -796,7 +796,7 @@ public Cffu> thenMApplyMostSuccessTupleAsync( } /** - * Tuple variance of {@link #thenMApplyMostSuccessAsync(Object, Executor, long, TimeUnit, Function[])} + * Tuple variance of {@link #thenMApplyMostSuccessAsync(Executor, Object, long, TimeUnit, Function[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} @@ -823,7 +823,7 @@ public Cffu> thenMApplyMostSuccessTupleA } /** - * Tuple variance of {@link #thenMApplyMostSuccessAsync(Object, Executor, long, TimeUnit, Function[])} + * Tuple variance of {@link #thenMApplyMostSuccessAsync(Executor, Object, long, TimeUnit, Function[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} @@ -851,7 +851,7 @@ public Cffu> thenMApplyMostSucce } /** - * Tuple variance of {@link #thenMApplyMostSuccessAsync(Object, Executor, long, TimeUnit, Function[])} + * Tuple variance of {@link #thenMApplyMostSuccessAsync(Executor, Object, long, TimeUnit, Function[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} @@ -1641,10 +1641,10 @@ public Cffu exceptionallyAsync(Function fn, Executor * * @param timeout how long to wait before completing exceptionally with a TimeoutException, in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter - * @see #orTimeout(Executor, long, TimeUnit) + * @see #orTimeout(long, TimeUnit, Executor) */ public Cffu orTimeout(long timeout, TimeUnit unit) { - return orTimeout(fac.defaultExecutor(), timeout, unit); + return orTimeout(timeout, unit, fac.defaultExecutor()); } /** @@ -1659,14 +1659,14 @@ public Cffu orTimeout(long timeout, TimeUnit unit) { * "https://github.com/foldright/cffu/blob/main/cffu-core/src/test/java/io/foldright/demo/CfDelayDysfunctionDemo.java" * >DelayDysfunctionDemo. * - * @param executorWhenTimeout the async executor when triggered by timeout * @param timeout how long to wait before completing exceptionally with a TimeoutException, * in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executorWhenTimeout the async executor when triggered by timeout */ - public Cffu orTimeout(Executor executorWhenTimeout, long timeout, TimeUnit unit) { + public Cffu orTimeout(long timeout, TimeUnit unit, Executor executorWhenTimeout) { checkMinimalStage(); - return resetCf(CompletableFutureUtils.cffuOrTimeout(cf, executorWhenTimeout, timeout, unit)); + return resetCf(CompletableFutureUtils.cffuOrTimeout(cf, timeout, unit, executorWhenTimeout)); } /** @@ -1722,10 +1722,10 @@ public Cffu unsafeOrTimeout(long timeout, TimeUnit unit) { * @param value the value to use upon timeout * @param timeout how long to wait before completing normally with the given value, in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter - * @see #completeOnTimeout(Object, Executor, long, TimeUnit) + * @see #completeOnTimeout(Object, long, TimeUnit, Executor) */ public Cffu completeOnTimeout(@Nullable T value, long timeout, TimeUnit unit) { - return completeOnTimeout(value, fac.defaultExecutor(), timeout, unit); + return completeOnTimeout(value, timeout, unit, fac.defaultExecutor()); } /** @@ -1741,13 +1741,13 @@ public Cffu completeOnTimeout(@Nullable T value, long timeout, TimeUnit unit) * >DelayDysfunctionDemo. * * @param value the value to use upon timeout - * @param executorWhenTimeout the async executor when triggered by timeout * @param timeout how long to wait before completing normally with the given value, in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executorWhenTimeout the async executor when triggered by timeout */ - public Cffu completeOnTimeout(@Nullable T value, Executor executorWhenTimeout, long timeout, TimeUnit unit) { + public Cffu completeOnTimeout(@Nullable T value, long timeout, TimeUnit unit, Executor executorWhenTimeout) { checkMinimalStage(); - return resetCf(CompletableFutureUtils.cffuCompleteOnTimeout(cf, value, executorWhenTimeout, timeout, unit)); + return resetCf(CompletableFutureUtils.cffuCompleteOnTimeout(cf, value, timeout, unit, executorWhenTimeout)); } /** 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 51a4835e..f5b9b455 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java @@ -195,7 +195,7 @@ public final Cffu> mSupplyFailFastAsync(Executor executor, Supplier< @SafeVarargs public final Cffu> mSupplyAllSuccessAsync( @Nullable T valueIfFailed, Supplier... suppliers) { - return mSupplyAllSuccessAsync(valueIfFailed, defaultExecutor, suppliers); + return mSupplyAllSuccessAsync(defaultExecutor, valueIfFailed, suppliers); } /** @@ -206,8 +206,8 @@ public final Cffu> mSupplyAllSuccessAsync( */ @SafeVarargs public final Cffu> mSupplyAllSuccessAsync( - @Nullable T valueIfFailed, Executor executor, Supplier... suppliers) { - return create(CompletableFutureUtils.mSupplyAllSuccessAsync(valueIfFailed, executor, suppliers)); + Executor executor, @Nullable T valueIfFailed, Supplier... suppliers) { + return create(CompletableFutureUtils.mSupplyAllSuccessAsync(executor, valueIfFailed, suppliers)); } /** @@ -220,7 +220,7 @@ public final Cffu> mSupplyAllSuccessAsync( @SafeVarargs public final Cffu> mSupplyMostSuccessAsync( @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier... suppliers) { - return mSupplyMostSuccessAsync(valueIfNotSuccess, defaultExecutor, timeout, unit, suppliers); + return mSupplyMostSuccessAsync(defaultExecutor, valueIfNotSuccess, timeout, unit, suppliers); } /** @@ -232,9 +232,9 @@ public final Cffu> mSupplyMostSuccessAsync( */ @SafeVarargs public final Cffu> mSupplyMostSuccessAsync( - @Nullable T valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, + Executor executor, @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier... suppliers) { - return create(CompletableFutureUtils.mSupplyMostSuccessAsync(valueIfNotSuccess, executor, timeout, unit, suppliers)); + return create(CompletableFutureUtils.mSupplyMostSuccessAsync(executor, valueIfNotSuccess, timeout, unit, suppliers)); } /** @@ -793,7 +793,7 @@ public final Cffu> allSuccessResultsOf( public final Cffu> mostSuccessResultsOf( @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage... cfs) { return create(CompletableFutureUtils.mostSuccessResultsOf( - valueIfNotSuccess, defaultExecutor, timeout, unit, cfs)); + defaultExecutor, valueIfNotSuccess, timeout, unit, 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 4fb9d6cf..4065d555 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -91,7 +91,7 @@ public static CompletableFuture> mSupplyFailFastAsync( @SafeVarargs public static CompletableFuture> mSupplyAllSuccessAsync( @Nullable T valueIfFailed, Supplier... suppliers) { - return mSupplyAllSuccessAsync(valueIfFailed, ASYNC_POOL, suppliers); + return mSupplyAllSuccessAsync(ASYNC_POOL, valueIfFailed, suppliers); } /** @@ -102,7 +102,7 @@ public static CompletableFuture> mSupplyAllSuccessAsync( */ @SafeVarargs public static CompletableFuture> mSupplyAllSuccessAsync( - @Nullable T valueIfFailed, Executor executor, Supplier... suppliers) { + Executor executor, @Nullable T valueIfFailed, Supplier... suppliers) { requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("supplier", suppliers); @@ -113,31 +113,31 @@ public static CompletableFuture> mSupplyAllSuccessAsync( * Shortcut to method {@link #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) mostSuccessResultsOf}, * wraps input suppliers to CompletableFuture by {@link CompletableFuture#supplyAsync(Supplier)}. *

- * See the {@link #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[]) mostSuccessResultsOf} + * See the {@link #mostSuccessResultsOf(Executor, Object, long, TimeUnit, CompletionStage[]) mostSuccessResultsOf} * documentation for the rules of result computation. */ @SafeVarargs public static CompletableFuture> mSupplyMostSuccessAsync( @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier... suppliers) { - return mSupplyMostSuccessAsync(valueIfNotSuccess, ASYNC_POOL, timeout, unit, suppliers); + return mSupplyMostSuccessAsync(ASYNC_POOL, valueIfNotSuccess, timeout, unit, suppliers); } /** - * Shortcut to method {@link #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[]) mostSuccessResultsOf}, + * Shortcut to method {@link #mostSuccessResultsOf(Executor, Object, long, TimeUnit, CompletionStage[]) mostSuccessResultsOf}, * wraps input suppliers to CompletableFuture by {@link CompletableFuture#supplyAsync(Supplier, Executor)}. *

- * See the {@link #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[]) mostSuccessResultsOf} + * See the {@link #mostSuccessResultsOf(Executor, Object, long, TimeUnit, CompletionStage[]) mostSuccessResultsOf} * documentation for the rules of result computation. */ @SafeVarargs public static CompletableFuture> mSupplyMostSuccessAsync( - @Nullable T valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, + Executor executor, @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier... suppliers) { requireNonNull(executor, "executor is null"); requireNonNull(unit, "unit is null"); requireArrayAndEleNonNull("supplier", suppliers); - return mostSuccessResultsOf0(valueIfNotSuccess, executor, timeout, unit, wrapSuppliers0(executor, suppliers)); + return mostSuccessResultsOf0(executor, valueIfNotSuccess, timeout, unit, wrapSuppliers0(executor, suppliers)); } /** @@ -442,7 +442,7 @@ public static CompletableFuture> mSupplyAllSuccessTupleA } /** - * Tuple variance of {@link #mSupplyAllSuccessAsync(Object, Executor, Supplier[])} with {@code null} valueIfFailed. + * Tuple variance of {@link #mSupplyAllSuccessAsync(Executor, Object, Supplier[])} with {@code null} valueIfFailed. *

* If any of the provided suppliers fails, its corresponding position will contain {@code null} * (which is indistinguishable from the supplier having a successful value of {@code null}). @@ -467,7 +467,7 @@ public static CompletableFuture> mSupplyAllSucce } /** - * Tuple variance of {@link #mSupplyAllSuccessAsync(Object, Executor, Supplier[])} with {@code null} valueIfFailed. + * Tuple variance of {@link #mSupplyAllSuccessAsync(Executor, Object, Supplier[])} with {@code null} valueIfFailed. *

* If any of the provided suppliers fails, its corresponding position will contain {@code null} * (which is indistinguishable from the supplier having a successful value of {@code null}). @@ -494,7 +494,7 @@ public static CompletableFuture> mSupply } /** - * Tuple variance of {@link #mSupplyAllSuccessAsync(Object, Executor, Supplier[])} with {@code null} valueIfFailed. + * Tuple variance of {@link #mSupplyAllSuccessAsync(Executor, Object, Supplier[])} with {@code null} valueIfFailed. *

* If any of the provided suppliers fails, its corresponding position will contain {@code null} * (which is indistinguishable from the supplier having a successful value of {@code null}). @@ -521,7 +521,7 @@ public static CompletableFuture> } /** - * Tuple variance of {@link #mSupplyAllSuccessAsync(Object, Executor, Supplier[])} with {@code null} valueIfFailed. + * Tuple variance of {@link #mSupplyAllSuccessAsync(Executor, Object, Supplier[])} with {@code null} valueIfFailed. *

* If any of the provided suppliers fails, its corresponding position will contain {@code null} * (which is indistinguishable from the supplier having a successful value of {@code null}). @@ -558,7 +558,7 @@ public static CompletableFuture> mSupplyMostSuccessTuple } /** - * Tuple variance of {@link #mSupplyMostSuccessAsync(Object, Executor, long, TimeUnit, Supplier[])} + * Tuple variance of {@link #mSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} @@ -587,7 +587,7 @@ public static CompletableFuture> mSupplyMostSucc } /** - * Tuple variance of {@link #mSupplyMostSuccessAsync(Object, Executor, long, TimeUnit, Supplier[])} + * Tuple variance of {@link #mSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} @@ -616,7 +616,7 @@ public static CompletableFuture> mSupply } /** - * Tuple variance of {@link #mSupplyMostSuccessAsync(Object, Executor, long, TimeUnit, Supplier[])} + * Tuple variance of {@link #mSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} @@ -646,7 +646,7 @@ public static CompletableFuture> } /** - * Tuple variance of {@link #mSupplyMostSuccessAsync(Object, Executor, long, TimeUnit, Supplier[])} + * Tuple variance of {@link #mSupplyMostSuccessAsync(Executor, Object, long, TimeUnit, Supplier[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} @@ -668,7 +668,7 @@ private static CompletableFuture f_mostSuccessTupleOf0( // MUST be *Non-Minimal* CF instances in order to read results(`getSuccessNow`), // otherwise UnsupportedOperationException final CompletableFuture[] cfArray = toNonMinCfArray0(stages); - return cffuCompleteOnTimeout(CompletableFuture.allOf(cfArray), null, executorWhenTimeout, timeout, unit) + return cffuCompleteOnTimeout(CompletableFuture.allOf(cfArray), null, timeout, unit, executorWhenTimeout) .handle((unused, ex) -> f_tupleOf0(f_mGetSuccessNow0(null, cfArray))); } @@ -844,7 +844,7 @@ private static CompletableFuture> allSuccessResultsOf0( @SafeVarargs public static CompletableFuture> mostSuccessResultsOf( @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage... cfs) { - return mostSuccessResultsOf(valueIfNotSuccess, ASYNC_POOL, timeout, unit, cfs); + return mostSuccessResultsOf(ASYNC_POOL, valueIfNotSuccess, timeout, unit, cfs); } /** @@ -860,8 +860,8 @@ public static CompletableFuture> mostSuccessResultsOf( * This method differs from {@link #allResultsFailFastOf allResultsFailFastOf} method in that it's tolerant of failed * or incomplete stages for any of the items, representing them as {@code valueIfNotSuccess} in the result list. * - * @param valueIfNotSuccess the value used as result if the input stage not completed normally * @param executorWhenTimeout the async executor when triggered by timeout + * @param valueIfNotSuccess the value used as result if the input stage not completed normally * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @throws NullPointerException if the cfs param or any of its elements are {@code null} @@ -870,17 +870,17 @@ public static CompletableFuture> mostSuccessResultsOf( @Contract(pure = true) @SafeVarargs public static CompletableFuture> mostSuccessResultsOf( - @Nullable T valueIfNotSuccess, Executor executorWhenTimeout, long timeout, TimeUnit unit, + Executor executorWhenTimeout, @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage... cfs) { requireNonNull(executorWhenTimeout, "executorWhenTimeout is null"); requireNonNull(unit, "unit is null"); requireCfsAndEleNonNull(cfs); - return mostSuccessResultsOf0(valueIfNotSuccess, executorWhenTimeout, timeout, unit, cfs); + return mostSuccessResultsOf0(executorWhenTimeout, valueIfNotSuccess, timeout, unit, cfs); } private static CompletableFuture> mostSuccessResultsOf0( - @Nullable T valueIfNotSuccess, Executor executorWhenTimeout, long timeout, TimeUnit unit, + Executor executorWhenTimeout, @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage[] cfs) { if (cfs.length == 0) return completedFuture(arrayList()); if (cfs.length == 1) { @@ -888,14 +888,14 @@ private static CompletableFuture> mostSuccessResultsOf0( // 1. avoid writing it by `cffuCompleteOnTimeout` and is able to read its result(`getSuccessNow`) // 2. ensure that the returned cf is not minimal-stage instance(UnsupportedOperationException) final CompletableFuture f = toNonMinCfCopy0(cfs[0]); - return cffuCompleteOnTimeout(f, valueIfNotSuccess, executorWhenTimeout, timeout, unit) + return cffuCompleteOnTimeout(f, valueIfNotSuccess, timeout, unit, executorWhenTimeout) .handle((unused, ex) -> arrayList(getSuccessNow(f, valueIfNotSuccess))); } // MUST be non-minimal-stage CF instances in order to read results(`getSuccessNow`), // otherwise UnsupportedOperationException final CompletableFuture[] cfArray = toNonMinCfArray0(cfs); - return cffuCompleteOnTimeout(CompletableFuture.allOf(cfArray), null, executorWhenTimeout, timeout, unit) + return cffuCompleteOnTimeout(CompletableFuture.allOf(cfArray), null, timeout, unit, executorWhenTimeout) .handle((unused, ex) -> arrayList(f_mGetSuccessNow0(valueIfNotSuccess, cfArray))); } @@ -1225,7 +1225,7 @@ public static CompletableFuture> mostSuccessTupleOf( } /** - * Tuple variance of {@link #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[])} + * Tuple variance of {@link #mostSuccessResultsOf(Executor, Object, long, TimeUnit, CompletionStage[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided stages is not completed normally, its corresponding position will contain {@code null} @@ -1257,7 +1257,7 @@ public static CompletableFuture> mostSuccessTupl } /** - * Tuple variance of {@link #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[])} + * Tuple variance of {@link #mostSuccessResultsOf(Executor, Object, long, TimeUnit, CompletionStage[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided stages is not completed normally, its corresponding position will contain {@code null} @@ -1290,7 +1290,7 @@ public static CompletableFuture> mostSuc } /** - * Tuple variance of {@link #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[])} + * Tuple variance of {@link #mostSuccessResultsOf(Executor, Object, long, TimeUnit, CompletionStage[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided stages is not completed normally, its corresponding position will contain {@code null} @@ -1324,7 +1324,7 @@ public static CompletableFuture> } /** - * Tuple variance of {@link #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[])} + * Tuple variance of {@link #mostSuccessResultsOf(Executor, Object, long, TimeUnit, CompletionStage[])} * with {@code null} valueIfNotSuccess. *

* If any of the provided stages is not completed normally, its corresponding position will contain {@code null} @@ -1527,7 +1527,7 @@ public static CompletableFuture> thenMApplyFailFastAsync( @SafeVarargs public static CompletableFuture> thenMApplyAllSuccessAsync( CompletableFuture cfThis, @Nullable U valueIfFailed, Function... fns) { - return thenMApplyAllSuccessAsync(cfThis, valueIfFailed, defaultExecutor(cfThis), fns); + return thenMApplyAllSuccessAsync(cfThis, defaultExecutor(cfThis), valueIfFailed, fns); } /** @@ -1543,8 +1543,8 @@ public static CompletableFuture> thenMApplyAllSuccessAsync( */ @SafeVarargs public static CompletableFuture> thenMApplyAllSuccessAsync( - CompletableFuture cfThis, @Nullable U valueIfFailed, - Executor executor, Function... fns) { + CompletableFuture cfThis, Executor executor, + @Nullable U valueIfFailed, Function... fns) { requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("fn", fns); @@ -1564,28 +1564,28 @@ public static CompletableFuture> thenMApplyAllSuccessAsync( public static CompletableFuture> thenMApplyMostSuccessAsync( CompletableFuture cfThis, @Nullable U valueIfNotSuccess, long timeout, TimeUnit unit, Function... fns) { - return thenMApplyMostSuccessAsync(cfThis, valueIfNotSuccess, defaultExecutor(cfThis), timeout, unit, fns); + return thenMApplyMostSuccessAsync(cfThis, defaultExecutor(cfThis), valueIfNotSuccess, timeout, unit, fns); } /** - * Shortcut to method {@link #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[]) + * Shortcut to method {@link #mostSuccessResultsOf(Executor, Object, long, TimeUnit, CompletionStage[]) * mostSuccessResultsOf}, wraps input functions to CompletableFuture by * {@link CompletableFuture#supplyAsync(Supplier, Executor)}; The given stage's result is used as the argument of functions. *

- * See the {@link #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[]) + * See the {@link #mostSuccessResultsOf(Executor, Object, long, TimeUnit, CompletionStage[]) * mostSuccessResultsOf} documentation for the rules of result computation. */ @SafeVarargs public static CompletableFuture> thenMApplyMostSuccessAsync( - CompletableFuture cfThis, @Nullable U valueIfNotSuccess, - Executor executor, long timeout, TimeUnit unit, Function... fns) { + CompletableFuture cfThis, Executor executor, @Nullable U valueIfNotSuccess, + long timeout, TimeUnit unit, Function... fns) { requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireNonNull(unit, "unit is null"); requireArrayAndEleNonNull("fn", fns); return cfThis.thenCompose(v -> mostSuccessResultsOf0( - valueIfNotSuccess, executor, timeout, unit, wrapFunctions0(executor, v, fns))); + executor, valueIfNotSuccess, timeout, unit, wrapFunctions0(executor, v, fns))); } /** @@ -2059,7 +2059,7 @@ public static CompletableFuture> thenMApplyAllSuccess } /** - * Tuple variance of {@link #thenMApplyAllSuccessAsync(CompletableFuture, Object, Executor, Function[])} + * Tuple variance of {@link #thenMApplyAllSuccessAsync(CompletableFuture, Executor, Object, Function[])} * with {@code null} valueIfFailed. *

* If any of the provided functions fails, its corresponding position will contain {@code null} @@ -2089,7 +2089,7 @@ public static CompletableFuture> thenMApplyAl } /** - * Tuple variance of {@link #thenMApplyAllSuccessAsync(CompletableFuture, Object, Executor, Function[])} + * Tuple variance of {@link #thenMApplyAllSuccessAsync(CompletableFuture, Executor, Object, Function[])} * with {@code null} valueIfFailed. *

* If any of the provided functions fails, its corresponding position will contain {@code null} @@ -2121,7 +2121,7 @@ public static CompletableFuture> then } /** - * Tuple variance of {@link #thenMApplyAllSuccessAsync(CompletableFuture, Object, Executor, Function[])} + * Tuple variance of {@link #thenMApplyAllSuccessAsync(CompletableFuture, Executor, Object, Function[])} * with {@code null} valueIfFailed. *

* If any of the provided functions fails, its corresponding position will contain {@code null} @@ -2153,7 +2153,7 @@ public static CompletableFuture * If any of the provided functions fails, its corresponding position will contain {@code null} @@ -2184,8 +2184,7 @@ public static CompletableFuture> thenMApplyMostSucces } /** - * Tuple variance of {@link #thenMApplyMostSuccessAsync( - *CompletableFuture, Object, Executor, long, TimeUnit, Function[])} with {@code null} valueIfNotSuccess. + * Tuple variance of {@link #thenMApplyMostSuccessAsync(CompletableFuture, Executor, Object, long, TimeUnit, Function[])} with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} * (which is indistinguishable from the supplier having a successful value of {@code null}). @@ -2215,8 +2214,7 @@ public static CompletableFuture> thenMApplyMo } /** - * Tuple variance of {@link #thenMApplyMostSuccessAsync( - *CompletableFuture, Object, Executor, long, TimeUnit, Function[])} with {@code null} valueIfNotSuccess. + * Tuple variance of {@link #thenMApplyMostSuccessAsync(CompletableFuture, Executor, Object, long, TimeUnit, Function[])} with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} * (which is indistinguishable from the supplier having a successful value of {@code null}). @@ -2248,8 +2246,7 @@ public static CompletableFuture> then } /** - * Tuple variance of {@link #thenMApplyMostSuccessAsync( - *CompletableFuture, Object, Executor, long, TimeUnit, Function[])} with {@code null} valueIfNotSuccess. + * Tuple variance of {@link #thenMApplyMostSuccessAsync(CompletableFuture, Executor, Object, long, TimeUnit, Function[])} with {@code null} valueIfNotSuccess. *

* If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} * (which is indistinguishable from the supplier having a successful value of {@code null}). @@ -2281,8 +2278,7 @@ public static CompletableFuture * If any of the provided suppliers is not completed normally, its corresponding position will contain {@code null} * (which is indistinguishable from the supplier having a successful value of {@code null}). @@ -2891,10 +2887,10 @@ C exceptionallyAsync(C cfThis, Function fn, Executor exe * * @param timeout how long to wait before completing exceptionally with a TimeoutException, in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter - * @see #cffuOrTimeout(CompletableFuture, Executor, long, TimeUnit) + * @see #cffuOrTimeout(CompletableFuture, long, TimeUnit, Executor) */ public static > C cffuOrTimeout(C cfThis, long timeout, TimeUnit unit) { - return cffuOrTimeout(cfThis, defaultExecutor(cfThis), timeout, unit); + return cffuOrTimeout(cfThis, timeout, unit, defaultExecutor(cfThis)); } /** @@ -2909,16 +2905,16 @@ public static > C cffuOrTimeout(C cfThis, long ti * "https://github.com/foldright/cffu/blob/main/cffu-core/src/test/java/io/foldright/demo/CfDelayDysfunctionDemo.java" * >DelayDysfunctionDemo. * - * @param executorWhenTimeout the async executor when triggered by timeout * @param timeout how long to wait before completing exceptionally with a TimeoutException, * in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executorWhenTimeout the async executor when triggered by timeout */ public static > C cffuOrTimeout( - C cfThis, Executor executorWhenTimeout, long timeout, TimeUnit unit) { + C cfThis, long timeout, TimeUnit unit, Executor executorWhenTimeout) { requireNonNull(cfThis, "cfThis is null"); - requireNonNull(executorWhenTimeout, "executorWhenTimeout is null"); requireNonNull(unit, "unit is null"); + requireNonNull(executorWhenTimeout, "executorWhenTimeout is null"); return hopExecutorIfAtCfDelayerThread(orTimeout(cfThis, timeout, unit), executorWhenTimeout); } @@ -2988,11 +2984,11 @@ public static > C orTimeout(C cfThis, long timeou * @param value the value to use upon timeout * @param timeout how long to wait before completing normally with the given value, in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter - * @see #cffuCompleteOnTimeout(CompletableFuture, Object, Executor, long, TimeUnit) + * @see #cffuCompleteOnTimeout(CompletableFuture, Object, long, TimeUnit, Executor) */ public static > C cffuCompleteOnTimeout(C cfThis, @Nullable T value, long timeout, TimeUnit unit) { - return cffuCompleteOnTimeout(cfThis, value, defaultExecutor(cfThis), timeout, unit); + return cffuCompleteOnTimeout(cfThis, value, timeout, unit, defaultExecutor(cfThis)); } /** @@ -3008,15 +3004,15 @@ C cffuCompleteOnTimeout(C cfThis, @Nullable T value, long timeout, TimeUnit unit * >DelayDysfunctionDemo. * * @param value the value to use upon timeout - * @param executorWhenTimeout the async executor when triggered by timeout * @param timeout how long to wait before completing normally with the given value, in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executorWhenTimeout the async executor when triggered by timeout */ public static > - C cffuCompleteOnTimeout(C cfThis, @Nullable T value, Executor executorWhenTimeout, long timeout, TimeUnit unit) { + C cffuCompleteOnTimeout(C cfThis, @Nullable T value, long timeout, TimeUnit unit, Executor executorWhenTimeout) { requireNonNull(cfThis, "cfThis is null"); - requireNonNull(executorWhenTimeout, "executorWhenTimeout is null"); requireNonNull(unit, "unit is null"); + requireNonNull(executorWhenTimeout, "executorWhenTimeout is null"); return hopExecutorIfAtCfDelayerThread(completeOnTimeout(cfThis, value, timeout, unit), executorWhenTimeout); } @@ -3031,8 +3027,7 @@ C cffuCompleteOnTimeout(C cfThis, @Nullable T value, Executor executorWhenTimeou * (including timeout function). So the long-running subsequent non-async actions lead to * the CompletableFuture dysfunction (including delay execution and timeout). *

- * Strong recommend using the safe method {@link #cffuCompleteOnTimeout(CompletableFuture, Object, - * Executor, long, TimeUnit)} instead of this method and {@link CompletableFuture#completeOnTimeout}.
+ * Strong recommend using the safe method {@link #cffuCompleteOnTimeout(CompletableFuture, Object, long, TimeUnit, Executor)} instead of this method and {@link CompletableFuture#completeOnTimeout}.
* Unless all subsequent actions of dependent CompletableFutures is ensured executing async(aka. the dependent * CompletableFutures is created by async methods), using this method and {@link CompletableFuture#completeOnTimeout} * is one less thread switch of task execution when triggered by timeout. @@ -3041,7 +3036,7 @@ C cffuCompleteOnTimeout(C cfThis, @Nullable T value, Executor executorWhenTimeou * @param timeout how long to wait before completing normally with the given value, in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return the given CompletableFuture - * @see #cffuCompleteOnTimeout(CompletableFuture, Object, Executor, long, TimeUnit) + * @see #cffuCompleteOnTimeout(CompletableFuture, Object, long, TimeUnit, Executor) */ @Contract("_, _, _, _ -> param1") public static > 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 d088471a..ab6a3467 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java @@ -83,9 +83,9 @@ void test_mSupply() throws Exception { testCffuFac.mSupplyFailFastAsync(supplier, supplier), testCffuFac.mSupplyFailFastAsync(testExecutor, supplier, supplier), testCffuFac.mSupplyAllSuccessAsync(anotherN, supplier, supplier), - testCffuFac.mSupplyAllSuccessAsync(anotherN, testExecutor, supplier, supplier), + testCffuFac.mSupplyAllSuccessAsync(testExecutor, anotherN, supplier, supplier), testCffuFac.mSupplyMostSuccessAsync(anotherN, LONG_WAIT_MS, MILLISECONDS, supplier, supplier), - testCffuFac.mSupplyMostSuccessAsync(anotherN, testExecutor, LONG_WAIT_MS, MILLISECONDS, supplier, supplier), + testCffuFac.mSupplyMostSuccessAsync(testExecutor, anotherN, LONG_WAIT_MS, MILLISECONDS, supplier, supplier), testCffuFac.mSupplyAsync(supplier, supplier), testCffuFac.mSupplyAsync(testExecutor, supplier, supplier), }; diff --git a/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java b/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java index f3b21ccf..d315b1c6 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java @@ -67,9 +67,9 @@ void test_thenMApply() throws Exception { completed.thenMApplyFailFastAsync(function_n, function_n), completed.thenMApplyFailFastAsync(testExecutor, function_n, function_n), completed.thenMApplyAllSuccessAsync(anotherN, function_n, function_n), - completed.thenMApplyAllSuccessAsync(anotherN, testExecutor, function_n, function_n), + completed.thenMApplyAllSuccessAsync(testExecutor, anotherN, function_n, function_n), completed.thenMApplyMostSuccessAsync(anotherN, LONG_WAIT_MS, MILLISECONDS, function_n, function_n), - completed.thenMApplyMostSuccessAsync(anotherN, testExecutor, LONG_WAIT_MS, MILLISECONDS, function_n, function_n), + completed.thenMApplyMostSuccessAsync(testExecutor, anotherN, LONG_WAIT_MS, MILLISECONDS, function_n, function_n), completed.thenMApplyAsync(function_n, function_n), completed.thenMApplyAsync(testExecutor, function_n, function_n) }; @@ -329,27 +329,27 @@ void test_timeout() throws Exception { testCffuFac.newIncompleteCffu().orTimeout(1, MILLISECONDS).get() ).getCause()); assertInstanceOf(TimeoutException.class, assertThrowsExactly(ExecutionException.class, () -> - testCffuFac.newIncompleteCffu().orTimeout(testExecutor, 1, MILLISECONDS).get() + testCffuFac.newIncompleteCffu().orTimeout(1, MILLISECONDS, testExecutor).get() ).getCause()); assertInstanceOf(TimeoutException.class, assertThrowsExactly(ExecutionException.class, () -> testCffuFac.newIncompleteCffu().unsafeOrTimeout(1, MILLISECONDS).get() ).getCause()); assertEquals(n, testCffuFac.completedFuture(n).orTimeout(1, MILLISECONDS).get()); - assertEquals(n, testCffuFac.completedFuture(n).orTimeout(testExecutor, 1, MILLISECONDS).get()); + assertEquals(n, testCffuFac.completedFuture(n).orTimeout(1, MILLISECONDS, testExecutor).get()); assertEquals(n, testCffuFac.completedFuture(n).unsafeOrTimeout(1, MILLISECONDS).get()); assertEquals(n, testCffuFac.newIncompleteCffu().completeOnTimeout( n, 1, MILLISECONDS).get()); assertEquals(n, testCffuFac.newIncompleteCffu().completeOnTimeout( - n, testExecutor, 1, MILLISECONDS).get()); + n, 1, MILLISECONDS, testExecutor).get()); assertEquals(n, testCffuFac.newIncompleteCffu().unsafeCompleteOnTimeout( n, 1, MILLISECONDS).get()); assertEquals(n, testCffuFac.completedFuture(n).completeOnTimeout( anotherN, 1, MILLISECONDS).get()); assertEquals(n, testCffuFac.completedFuture(n).completeOnTimeout( - anotherN, testExecutor, 1, MILLISECONDS).get()); + anotherN, 1, MILLISECONDS, testExecutor).get()); assertEquals(n, testCffuFac.completedFuture(n).unsafeCompleteOnTimeout( anotherN, 1, MILLISECONDS).get()); } diff --git a/cffu-core/src/test/java/io/foldright/cffu/CheckExecutorTests.kt b/cffu-core/src/test/java/io/foldright/cffu/CheckExecutorTests.kt index 43af3625..e3a39091 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CheckExecutorTests.kt +++ b/cffu-core/src/test/java/io/foldright/cffu/CheckExecutorTests.kt @@ -22,9 +22,9 @@ class CheckExecutorTests : FunSpec({ CompletableFutureUtils.mSupplyFailFastAsync(testExecutor, *am.createSuppliers(count, testExecutor)) CompletableFutureUtils.mSupplyAllSuccessAsync(null, *am.createSuppliers(count)) - CompletableFutureUtils.mSupplyAllSuccessAsync( - null, + CompletableFutureUtils.mSupplyAllSuccessAsync( testExecutor, + null, *am.createSuppliers(count, testExecutor) ) @@ -35,8 +35,8 @@ class CheckExecutorTests : FunSpec({ *am.createSuppliers(count) ) CompletableFutureUtils.mSupplyMostSuccessAsync( - null, testExecutor, + null, LONG_WAIT_MS, MILLISECONDS, *am.createSuppliers(count, testExecutor) @@ -277,10 +277,10 @@ class CheckExecutorTests : FunSpec({ ) CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, null, *am.createFunctions(count)) - CompletableFutureUtils.thenMApplyAllSuccessAsync( + CompletableFutureUtils.thenMApplyAllSuccessAsync( cfThis, - null, testExecutor, + null, *am.createFunctions(count, testExecutor) ) @@ -293,8 +293,8 @@ class CheckExecutorTests : FunSpec({ ) CompletableFutureUtils.thenMApplyMostSuccessAsync( cfThis, - null, testExecutor, + null, LONG_WAIT_MS, MILLISECONDS, *am.createFunctions(count, testExecutor) diff --git a/cffu-core/src/test/java/io/foldright/cffu/CheckMinStageRuntimeTypeTests.kt b/cffu-core/src/test/java/io/foldright/cffu/CheckMinStageRuntimeTypeTests.kt index 441ed7ea..32e3eb08 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CheckMinStageRuntimeTypeTests.kt +++ b/cffu-core/src/test/java/io/foldright/cffu/CheckMinStageRuntimeTypeTests.kt @@ -36,19 +36,19 @@ private class CheckMinStageRuntimeTypeTests { CompletableFutureUtils.mSupplyAllSuccessAsync("").shouldNotBeMinimalStage() CompletableFutureUtils.mSupplyAllSuccessAsync("", Supplier { s }).shouldNotBeMinimalStage() CompletableFutureUtils.mSupplyAllSuccessAsync("", Supplier { s }, { s }).shouldNotBeMinimalStage() - CompletableFutureUtils.mSupplyAllSuccessAsync("", testExecutor).shouldNotBeMinimalStage() - CompletableFutureUtils.mSupplyAllSuccessAsync("", testExecutor, { s }).shouldNotBeMinimalStage() - CompletableFutureUtils.mSupplyAllSuccessAsync("", testExecutor, { s }, { s }).shouldNotBeMinimalStage() + CompletableFutureUtils.mSupplyAllSuccessAsync(testExecutor, "").shouldNotBeMinimalStage() + CompletableFutureUtils.mSupplyAllSuccessAsync(testExecutor, "", { s }).shouldNotBeMinimalStage() + CompletableFutureUtils.mSupplyAllSuccessAsync(testExecutor, "", { s }, { s }).shouldNotBeMinimalStage() CompletableFutureUtils.mSupplyMostSuccessAsync("", 1, MILLISECONDS).shouldNotBeMinimalStage() CompletableFutureUtils.mSupplyMostSuccessAsync("", 1, MILLISECONDS, Supplier { s }).shouldNotBeMinimalStage() CompletableFutureUtils.mSupplyMostSuccessAsync("", 1, MILLISECONDS, Supplier { s }, { s }) .shouldNotBeMinimalStage() - CompletableFutureUtils.mSupplyMostSuccessAsync("", testExecutor, 1, MILLISECONDS) + CompletableFutureUtils.mSupplyMostSuccessAsync(testExecutor, "", 1, MILLISECONDS) .shouldNotBeMinimalStage() - CompletableFutureUtils.mSupplyMostSuccessAsync("", testExecutor, 1, MILLISECONDS, Supplier { s }) + CompletableFutureUtils.mSupplyMostSuccessAsync(testExecutor, "", 1, MILLISECONDS, Supplier { s }) .shouldNotBeMinimalStage() - CompletableFutureUtils.mSupplyMostSuccessAsync("", testExecutor, 1, MILLISECONDS, Supplier { s }, { s }) + CompletableFutureUtils.mSupplyMostSuccessAsync(testExecutor, "", 1, MILLISECONDS, Supplier { s }, { s }) .shouldNotBeMinimalStage() CompletableFutureUtils.mSupplyAsync().shouldNotBeMinimalStage() @@ -166,9 +166,9 @@ private class CheckMinStageRuntimeTypeTests { CompletableFutureUtils.mostSuccessResultsOf("", 1, MILLISECONDS).shouldNotBeMinimalStage() CompletableFutureUtils.mostSuccessResultsOf("", 1, MILLISECONDS, cfN).shouldNotBeMinimalStage() CompletableFutureUtils.mostSuccessResultsOf("", 1, MILLISECONDS, cfN, cfAn).shouldNotBeMinimalStage() - CompletableFutureUtils.mostSuccessResultsOf("", testExecutor, 1, MILLISECONDS).shouldNotBeMinimalStage() - CompletableFutureUtils.mostSuccessResultsOf("", testExecutor, 1, MILLISECONDS, cfN).shouldNotBeMinimalStage() - CompletableFutureUtils.mostSuccessResultsOf("", testExecutor, 1, MILLISECONDS, cfN, cfAn) + CompletableFutureUtils.mostSuccessResultsOf(testExecutor, "", 1, MILLISECONDS).shouldNotBeMinimalStage() + CompletableFutureUtils.mostSuccessResultsOf(testExecutor, "", 1, MILLISECONDS, cfN).shouldNotBeMinimalStage() + CompletableFutureUtils.mostSuccessResultsOf(testExecutor, "", 1, MILLISECONDS, cfN, cfAn) .shouldNotBeMinimalStage() CompletableFutureUtils.allResultsOf().shouldNotBeMinimalStage() @@ -239,9 +239,9 @@ private class CheckMinStageRuntimeTypeTests { CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, "").shouldNotBeMinimalStage() CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, "", Function { s }).shouldNotBeMinimalStage() CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, "", Function { s }, { s }).shouldNotBeMinimalStage() - CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, "", testExecutor).shouldNotBeMinimalStage() - CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, "", testExecutor, { s }).shouldNotBeMinimalStage() - CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, "", testExecutor, { s }, { s }) + CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, testExecutor, "").shouldNotBeMinimalStage() + CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, testExecutor, "", { s }).shouldNotBeMinimalStage() + CompletableFutureUtils.thenMApplyAllSuccessAsync(cfThis, testExecutor, "", { s }, { s }) .shouldNotBeMinimalStage() CompletableFutureUtils.thenMApplyMostSuccessAsync(cfThis, "", 1, MILLISECONDS) @@ -250,14 +250,14 @@ private class CheckMinStageRuntimeTypeTests { .shouldNotBeMinimalStage() CompletableFutureUtils.thenMApplyMostSuccessAsync(cfThis, "", 1, MILLISECONDS, Function { s }, { s }) .shouldNotBeMinimalStage() - CompletableFutureUtils.thenMApplyMostSuccessAsync(cfThis, "", testExecutor, 1, MILLISECONDS) + CompletableFutureUtils.thenMApplyMostSuccessAsync(cfThis, testExecutor, "", 1, MILLISECONDS) .shouldNotBeMinimalStage() - CompletableFutureUtils.thenMApplyMostSuccessAsync(cfThis, "", testExecutor, 1, MILLISECONDS, Function { s }) + CompletableFutureUtils.thenMApplyMostSuccessAsync(cfThis, testExecutor, "", 1, MILLISECONDS, Function { s }) .shouldNotBeMinimalStage() CompletableFutureUtils.thenMApplyMostSuccessAsync( cfThis, - "", testExecutor, + "", 1, MILLISECONDS, Function { s }, @@ -430,11 +430,11 @@ private class CheckMinStageRuntimeTypeTests { // Timeout Control Methods of CompletableFuture CompletableFutureUtils.cffuOrTimeout(cfThis, 1, MILLISECONDS).shouldNotBeMinimalStage() - CompletableFutureUtils.cffuOrTimeout(cfThis, testExecutor, 1, MILLISECONDS).shouldNotBeMinimalStage() + CompletableFutureUtils.cffuOrTimeout(cfThis, 1, MILLISECONDS, testExecutor).shouldNotBeMinimalStage() CompletableFutureUtils.orTimeout(cfThis, 1, MILLISECONDS).shouldNotBeMinimalStage() CompletableFutureUtils.cffuCompleteOnTimeout(cfThis, "", 1, MILLISECONDS).shouldNotBeMinimalStage() - CompletableFutureUtils.cffuCompleteOnTimeout(cfThis, "", testExecutor, 1, MILLISECONDS) + CompletableFutureUtils.cffuCompleteOnTimeout(cfThis, "", 1, MILLISECONDS, testExecutor) .shouldNotBeMinimalStage() CompletableFutureUtils.completeOnTimeout(cfThis, "", 1, MILLISECONDS).shouldNotBeMinimalStage() @@ -506,19 +506,19 @@ private class CheckMinStageRuntimeTypeTests { testCffuFac.mSupplyAllSuccessAsync("").shouldNotBeMinimalStage() testCffuFac.mSupplyAllSuccessAsync("", Supplier { s }).shouldNotBeMinimalStage() testCffuFac.mSupplyAllSuccessAsync("", Supplier { s }, { s }).shouldNotBeMinimalStage() - testCffuFac.mSupplyAllSuccessAsync("", testFjExecutor).shouldNotBeMinimalStage() - testCffuFac.mSupplyAllSuccessAsync("", testFjExecutor, { s }).shouldNotBeMinimalStage() - testCffuFac.mSupplyAllSuccessAsync("", testFjExecutor, { s }, { s }).shouldNotBeMinimalStage() + testCffuFac.mSupplyAllSuccessAsync(testFjExecutor, "").shouldNotBeMinimalStage() + testCffuFac.mSupplyAllSuccessAsync(testFjExecutor, "", { s }).shouldNotBeMinimalStage() + testCffuFac.mSupplyAllSuccessAsync(testFjExecutor, "", { s }, { s }).shouldNotBeMinimalStage() testCffuFac.mSupplyMostSuccessAsync("", 1, MILLISECONDS).shouldNotBeMinimalStage() testCffuFac.mSupplyMostSuccessAsync("", 1, MILLISECONDS, Supplier { s }).shouldNotBeMinimalStage() testCffuFac.mSupplyMostSuccessAsync("", 1, MILLISECONDS, Supplier { s }, { s }) .shouldNotBeMinimalStage() - testCffuFac.mSupplyMostSuccessAsync("", testFjExecutor, 1, MILLISECONDS) + testCffuFac.mSupplyMostSuccessAsync(testFjExecutor, "", 1, MILLISECONDS) .shouldNotBeMinimalStage() - testCffuFac.mSupplyMostSuccessAsync("", testFjExecutor, 1, MILLISECONDS, Supplier { s }) + testCffuFac.mSupplyMostSuccessAsync(testFjExecutor, "", 1, MILLISECONDS, Supplier { s }) .shouldNotBeMinimalStage() - testCffuFac.mSupplyMostSuccessAsync("", testFjExecutor, 1, MILLISECONDS, Supplier { s }, { s }) + testCffuFac.mSupplyMostSuccessAsync(testFjExecutor, "", 1, MILLISECONDS, Supplier { s }, { s }) .shouldNotBeMinimalStage() testCffuFac.mSupplyAsync().shouldNotBeMinimalStage() @@ -720,17 +720,17 @@ private class CheckMinStageRuntimeTypeTests { cffuThis.thenMApplyAllSuccessAsync("").shouldNotBeMinimalStage() cffuThis.thenMApplyAllSuccessAsync("", Function { s }).shouldNotBeMinimalStage() cffuThis.thenMApplyAllSuccessAsync("", Function { s }, { s }).shouldNotBeMinimalStage() - cffuThis.thenMApplyAllSuccessAsync("", testFjExecutor).shouldNotBeMinimalStage() - cffuThis.thenMApplyAllSuccessAsync("", testFjExecutor, { s }).shouldNotBeMinimalStage() - cffuThis.thenMApplyAllSuccessAsync("", testFjExecutor, { s }, { s }).shouldNotBeMinimalStage() + cffuThis.thenMApplyAllSuccessAsync(testFjExecutor, "").shouldNotBeMinimalStage() + cffuThis.thenMApplyAllSuccessAsync(testFjExecutor, "", { s }).shouldNotBeMinimalStage() + cffuThis.thenMApplyAllSuccessAsync(testFjExecutor, "", { s }, { s }).shouldNotBeMinimalStage() cffuThis.thenMApplyMostSuccessAsync("", 1, MILLISECONDS).shouldNotBeMinimalStage() cffuThis.thenMApplyMostSuccessAsync("", 1, MILLISECONDS, Function { s }).shouldNotBeMinimalStage() cffuThis.thenMApplyMostSuccessAsync("", 1, MILLISECONDS, Function { s }, { s }).shouldNotBeMinimalStage() - cffuThis.thenMApplyMostSuccessAsync("", testFjExecutor, 1, MILLISECONDS).shouldNotBeMinimalStage() - cffuThis.thenMApplyMostSuccessAsync("", testFjExecutor, 1, MILLISECONDS, Function { s }) + cffuThis.thenMApplyMostSuccessAsync(testFjExecutor, "", 1, MILLISECONDS).shouldNotBeMinimalStage() + cffuThis.thenMApplyMostSuccessAsync(testFjExecutor, "", 1, MILLISECONDS, Function { s }) .shouldNotBeMinimalStage() - cffuThis.thenMApplyMostSuccessAsync("", testFjExecutor, 1, MILLISECONDS, Function { s }, { s }) + cffuThis.thenMApplyMostSuccessAsync(testFjExecutor, "", 1, MILLISECONDS, Function { s }, { s }) .shouldNotBeMinimalStage() cffuThis.thenMApplyAsync().shouldNotBeMinimalStage() @@ -896,11 +896,11 @@ private class CheckMinStageRuntimeTypeTests { // Timeout Control Methods of CompletableFuture cffuThis.orTimeout(1, MILLISECONDS).shouldNotBeMinimalStage() - cffuThis.orTimeout(testFjExecutor, 1, MILLISECONDS).shouldNotBeMinimalStage() + cffuThis.orTimeout(1, MILLISECONDS, testFjExecutor).shouldNotBeMinimalStage() cffuThis.unsafeOrTimeout(1, MILLISECONDS).shouldNotBeMinimalStage() cffuThis.completeOnTimeout("", 1, MILLISECONDS).shouldNotBeMinimalStage() - cffuThis.completeOnTimeout("", testFjExecutor, 1, MILLISECONDS).shouldNotBeMinimalStage() + cffuThis.completeOnTimeout("", 1, MILLISECONDS, testFjExecutor).shouldNotBeMinimalStage() cffuThis.unsafeCompleteOnTimeout("", 1, MILLISECONDS).shouldNotBeMinimalStage() // Advanced Methods of CompletionStage(compose* and handle-like methods) 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 4294aab6..545bf779 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java @@ -56,9 +56,9 @@ void test_mSupply() throws Exception { mSupplyFailFastAsync(supplier, supplier), mSupplyFailFastAsync(testExecutor, supplier, supplier), mSupplyAllSuccessAsync(anotherN, supplier, supplier), - mSupplyAllSuccessAsync(anotherN, testExecutor, supplier, supplier), + mSupplyAllSuccessAsync(testExecutor, anotherN, supplier, supplier), mSupplyMostSuccessAsync(anotherN, LONG_WAIT_MS, MILLISECONDS, supplier, supplier), - mSupplyMostSuccessAsync(anotherN, testExecutor, LONG_WAIT_MS, MILLISECONDS, supplier, supplier), + mSupplyMostSuccessAsync(testExecutor, anotherN, LONG_WAIT_MS, MILLISECONDS, supplier, supplier), mSupplyAsync(supplier, supplier), mSupplyAsync(testExecutor, supplier, supplier), }; @@ -1054,9 +1054,9 @@ void test_thenMApply() throws Exception { thenMApplyFailFastAsync(completed, supplier, supplier), thenMApplyFailFastAsync(completed, testExecutor, supplier, supplier), thenMApplyAllSuccessAsync(completed, anotherN, supplier, supplier), - thenMApplyAllSuccessAsync(completed, anotherN, testExecutor, supplier, supplier), + thenMApplyAllSuccessAsync(completed, testExecutor, anotherN, supplier, supplier), thenMApplyMostSuccessAsync(completed, anotherN, LONG_WAIT_MS, MILLISECONDS, supplier, supplier), - thenMApplyMostSuccessAsync(completed, anotherN, testExecutor, LONG_WAIT_MS, MILLISECONDS, supplier, supplier), + thenMApplyMostSuccessAsync(completed, testExecutor, anotherN, LONG_WAIT_MS, MILLISECONDS, supplier, supplier), thenMApplyAsync(completed, supplier, supplier), thenMApplyAsync(completed, testExecutor, supplier, supplier), }; @@ -1434,20 +1434,20 @@ void test_timeout() throws Exception { cffuOrTimeout(incompleteCf(), SHORT_WAIT_MS, MILLISECONDS).get() ).getCause()); assertInstanceOf(TimeoutException.class, assertThrowsExactly(ExecutionException.class, () -> - cffuOrTimeout(incompleteCf(), testExecutor, SHORT_WAIT_MS, MILLISECONDS).get() + cffuOrTimeout(incompleteCf(), SHORT_WAIT_MS, MILLISECONDS, testExecutor).get() ).getCause()); assertEquals(n, orTimeout(completedFuture(n), SHORT_WAIT_MS, MILLISECONDS).get()); assertEquals(n, cffuOrTimeout(completedFuture(n), SHORT_WAIT_MS, MILLISECONDS).get()); - assertEquals(n, cffuOrTimeout(completedFuture(n), testExecutor, SHORT_WAIT_MS, MILLISECONDS).get()); + assertEquals(n, cffuOrTimeout(completedFuture(n), SHORT_WAIT_MS, MILLISECONDS, testExecutor).get()); assertEquals(n, completeOnTimeout(incompleteCf(), n, SHORT_WAIT_MS, MILLISECONDS).get()); assertEquals(n, cffuCompleteOnTimeout(incompleteCf(), n, SHORT_WAIT_MS, MILLISECONDS).get()); - assertEquals(n, cffuCompleteOnTimeout(incompleteCf(), n, testExecutor, SHORT_WAIT_MS, MILLISECONDS).get()); + assertEquals(n, cffuCompleteOnTimeout(incompleteCf(), n, SHORT_WAIT_MS, MILLISECONDS, testExecutor).get()); assertEquals(n, completeOnTimeout(completedFuture(n), anotherN, SHORT_WAIT_MS, MILLISECONDS).get()); assertEquals(n, cffuCompleteOnTimeout(completedFuture(n), anotherN, SHORT_WAIT_MS, MILLISECONDS).get()); - assertEquals(n, cffuCompleteOnTimeout(completedFuture(n), anotherN, testExecutor, SHORT_WAIT_MS, MILLISECONDS).get()); + assertEquals(n, cffuCompleteOnTimeout(completedFuture(n), anotherN, SHORT_WAIT_MS, MILLISECONDS, testExecutor).get()); } @Test @@ -1472,7 +1472,7 @@ void test_safeBehavior_orTimeout() { }) ).collect(Collectors.toList()).stream().map(CompletableFuture::join).collect(Collectors.toList())); assertEquals(results, results.stream().map(i -> - cffuOrTimeout(incompleteCf(), testExecutor, SHORT_WAIT_MS, MILLISECONDS).handle((v, ex) -> { + cffuOrTimeout(incompleteCf(), SHORT_WAIT_MS, MILLISECONDS, testExecutor).handle((v, ex) -> { assertInstanceOf(TimeoutException.class, ex); assertFalse(Delayer.atCfDelayerThread()); assertRunningInExecutor(testExecutor); @@ -1503,7 +1503,7 @@ void test_safeBehavior_completeOnTimeout() { }) ).collect(Collectors.toList()).stream().map(CompletableFuture::join).collect(Collectors.toList())); assertEquals(results, results.stream().map(i -> - cffuCompleteOnTimeout(incompleteCf(), i, testExecutor, SHORT_WAIT_MS, MILLISECONDS).handle((v, ex) -> { + cffuCompleteOnTimeout(incompleteCf(), i, SHORT_WAIT_MS, MILLISECONDS, testExecutor).handle((v, ex) -> { assertNull(ex); assertFalse(Delayer.atCfDelayerThread()); assertRunningInExecutor(testExecutor); 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 8e1fba32..7a565c15 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 @@ -99,7 +99,7 @@ fun Array>.mSupplyFailFastAsyncCffu( */ fun Collection>.mSupplyAllSuccessAsyncCffu( cffuFactory: CffuFactory, valueIfFailed: T, executor: Executor = cffuFactory.defaultExecutor() -): Cffu> = cffuFactory.mSupplyAllSuccessAsync(valueIfFailed, executor, *toTypedArray()) +): Cffu> = cffuFactory.mSupplyAllSuccessAsync(executor, valueIfFailed, *toTypedArray()) /** * Returns a new Cffu that is asynchronously completed @@ -116,7 +116,7 @@ fun Collection>.mSupplyAllSuccessAsyncCffu( */ fun Array>.mSupplyAllSuccessAsyncCffu( cffuFactory: CffuFactory, valueIfFailed: T, executor: Executor = cffuFactory.defaultExecutor() -): Cffu> = cffuFactory.mSupplyAllSuccessAsync(valueIfFailed, executor, *this) +): Cffu> = cffuFactory.mSupplyAllSuccessAsync(executor, valueIfFailed, *this) /** * Returns a new Cffu that is asynchronously completed @@ -138,7 +138,7 @@ fun Array>.mSupplyAllSuccessAsyncCffu( fun Collection>.mSupplyMostSuccessAsyncCffu( cffuFactory: CffuFactory, valueIfNotSuccess: T, timeout: Long, unit: TimeUnit, executor: Executor = cffuFactory.defaultExecutor() -): Cffu> = cffuFactory.mSupplyMostSuccessAsync(valueIfNotSuccess, executor, timeout, unit, *toTypedArray()) +): Cffu> = cffuFactory.mSupplyMostSuccessAsync(executor, valueIfNotSuccess, timeout, unit, *toTypedArray()) /** * Returns a new Cffu that is asynchronously completed @@ -160,7 +160,7 @@ fun Collection>.mSupplyMostSuccessAsyncCffu( fun Array>.mSupplyMostSuccessAsyncCffu( cffuFactory: CffuFactory, valueIfNotSuccess: T, timeout: Long, unit: TimeUnit, executor: Executor = cffuFactory.defaultExecutor() -): Cffu> = cffuFactory.mSupplyMostSuccessAsync(valueIfNotSuccess, executor, timeout, unit, *this) +): Cffu> = cffuFactory.mSupplyMostSuccessAsync(executor, valueIfNotSuccess, timeout, unit, *this) /** * Returns a new Cffu that is asynchronously completed 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 bf5d8afa..0c83bf21 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 @@ -78,7 +78,7 @@ fun Array>.mSupplyFailFastAsyncCompletableFuture(executo fun Collection>.mSupplyAllSuccessAsyncCompletableFuture( valueIfFailed: T, executor: Executor = ASYNC_POOL ): CompletableFuture> = - CompletableFutureUtils.mSupplyAllSuccessAsync(valueIfFailed, executor, *toTypedArray()) + CompletableFutureUtils.mSupplyAllSuccessAsync(executor, valueIfFailed, *toTypedArray()) /** * Returns a new CompletableFuture that is asynchronously completed @@ -96,7 +96,7 @@ fun Collection>.mSupplyAllSuccessAsyncCompletableFuture( fun Array>.mSupplyAllSuccessAsyncCompletableFuture( valueIfFailed: T, executor: Executor = ASYNC_POOL ): CompletableFuture> = - CompletableFutureUtils.mSupplyAllSuccessAsync(valueIfFailed, executor, *this) + CompletableFutureUtils.mSupplyAllSuccessAsync(executor, valueIfFailed, *this) /** * Returns a new CompletableFuture that is asynchronously completed @@ -119,7 +119,7 @@ fun Array>.mSupplyAllSuccessAsyncCompletableFuture( fun Collection>.mSupplyMostSuccessAsyncCompletableFuture( valueIfNotSuccess: T, timeout: Long, unit: TimeUnit, executor: Executor = ASYNC_POOL ): CompletableFuture> = - CompletableFutureUtils.mSupplyMostSuccessAsync(valueIfNotSuccess, executor, timeout, unit, *toTypedArray()) + CompletableFutureUtils.mSupplyMostSuccessAsync(executor, valueIfNotSuccess, timeout, unit, *toTypedArray()) /** * Returns a new CompletableFuture that is asynchronously completed @@ -142,7 +142,7 @@ fun Collection>.mSupplyMostSuccessAsyncCompletableFuture( fun Array>.mSupplyMostSuccessAsyncCompletableFuture( valueIfNotSuccess: T, timeout: Long, unit: TimeUnit, executor: Executor = ASYNC_POOL ): CompletableFuture> = - CompletableFutureUtils.mSupplyMostSuccessAsync(valueIfNotSuccess, executor, timeout, unit, *this) + CompletableFutureUtils.mSupplyMostSuccessAsync(executor, valueIfNotSuccess, timeout, unit, *this) /** * Returns a new CompletableFuture that is asynchronously completed @@ -444,7 +444,7 @@ fun Array>.mostSuccessResultsOfCompletableFuture( fun Collection>.mostSuccessResultsOfCompletableFuture( valueIfNotSuccess: T, executorWhenTimeout: Executor, timeout: Long, unit: TimeUnit ): CompletableFuture> = - CompletableFutureUtils.mostSuccessResultsOf(valueIfNotSuccess, executorWhenTimeout, timeout, unit, *toTypedArray()) + CompletableFutureUtils.mostSuccessResultsOf(executorWhenTimeout, valueIfNotSuccess, timeout, unit, *toTypedArray()) /** * Returns a new CompletableFuture with the most results in the **same order** of the given stages arguments @@ -462,7 +462,7 @@ fun Collection>.mostSuccessResultsOfCompletableFuture fun Array>.mostSuccessResultsOfCompletableFuture( valueIfNotSuccess: T, executorWhenTimeout: Executor, timeout: Long, unit: TimeUnit ): CompletableFuture> = - CompletableFutureUtils.mostSuccessResultsOf(valueIfNotSuccess, executorWhenTimeout, timeout, unit, *this) + CompletableFutureUtils.mostSuccessResultsOf(executorWhenTimeout, valueIfNotSuccess, timeout, unit, *this) /** * Returns a new CompletableFuture with the results in the **same order** of all the given CompletableFutures arguments, @@ -708,7 +708,7 @@ fun CompletableFuture.thenMApplyAllSuccessAsync( */ fun CompletableFuture.thenMApplyAllSuccessAsync( valueIfFailed: U, executor: Executor, vararg fns: Function -): CompletableFuture> = CompletableFutureUtils.thenMApplyAllSuccessAsync(this, valueIfFailed, executor, *fns) +): CompletableFuture> = CompletableFutureUtils.thenMApplyAllSuccessAsync(this, executor, valueIfFailed, *fns) /** * Returns a new CompletableFuture that, when the given stage completes normally, @@ -754,7 +754,7 @@ fun CompletableFuture.thenMApplyMostSuccessAsync( fun CompletableFuture.thenMApplyMostSuccessAsync( valueIfNotSuccess: U, executor: Executor, timeout: Long, unit: TimeUnit, vararg fns: Function ): CompletableFuture> = - CompletableFutureUtils.thenMApplyMostSuccessAsync(this, valueIfNotSuccess, executor, timeout, unit, *fns) + CompletableFutureUtils.thenMApplyMostSuccessAsync(this, executor, valueIfNotSuccess, timeout, unit, *fns) /** * Returns a new CompletableFuture that, when the given stage completes normally, @@ -1730,7 +1730,7 @@ fun > C.cffuOrTimeout(timeout: Long, unit: TimeUnit): C * @param unit a `TimeUnit` determining how to interpret the `timeout` parameter */ fun > C.cffuOrTimeout(executorWhenTimeout: Executor, timeout: Long, unit: TimeUnit): C = - CompletableFutureUtils.cffuOrTimeout(this, executorWhenTimeout, timeout, unit) + CompletableFutureUtils.cffuOrTimeout(this, timeout, unit, executorWhenTimeout) /** * Exceptionally completes this CompletableFuture with a [TimeoutException] @@ -1799,7 +1799,7 @@ fun > C.cffuCompleteOnTimeout( */ fun > C.cffuCompleteOnTimeout( value: T, executorWhenTimeout: Executor, timeout: Long, unit: TimeUnit -): C = CompletableFutureUtils.cffuCompleteOnTimeout(this, value, executorWhenTimeout, timeout, unit) +): C = CompletableFutureUtils.cffuCompleteOnTimeout(this, value, timeout, unit, executorWhenTimeout) /** * Completes this CompletableFuture with the given value if not otherwise completed before the given timeout.