Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Jun 16, 2024
1 parent 106422e commit ec5604e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public final <T> Cffu<List<T>> allResultsOfFastFail(CompletionStage<? extends T>
public final <T> Cffu<List<T>> mostResultsOfSuccess(
long timeout, TimeUnit unit, @Nullable T valueIfNotSuccess, CompletionStage<? extends T>... cfs) {
return create(CompletableFutureUtils.mostResultsOfSuccess(
defaultExecutor, timeout, unit, valueIfNotSuccess, cfs));
valueIfNotSuccess, defaultExecutor, timeout, unit, cfs));
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public static <T> CompletableFuture<List<T>> mSupplyMostSuccessAsync(
* @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 CompletableFuture
* @return the new CompletableFuture
* @see #mostResultsOfSuccess(Executor, long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Object, Executor, long, TimeUnit, CompletionStage[])
* @see CompletableFuture#supplyAsync(Supplier, Executor)
*/
@SafeVarargs
Expand All @@ -251,7 +251,7 @@ public static <T> CompletableFuture<List<T>> mSupplyMostSuccessAsync(
requireNonNull(unit, "unit is null");
requireArrayAndEleNonNull("supplier", suppliers);

return mostResultsOfSuccess(executor, timeout, unit, valueIfNotSuccess, wrapSuppliers(executor, suppliers));
return mostResultsOfSuccess(valueIfNotSuccess, executor, timeout, unit, wrapSuppliers(executor, suppliers));
}

private static <T> CompletableFuture<? extends T>[] wrapSuppliers(
Expand Down Expand Up @@ -290,7 +290,7 @@ private static <T> CompletableFuture<? extends T>[] wrapSuppliers(
* If you need the successful results of given stages in the given time, prefer below methods:
* <ul>
* <li>{@link #mostResultsOfSuccess(long, TimeUnit, Object, CompletionStage[])}
* <li>{@link #mostResultsOfSuccess(Executor, long, TimeUnit, Object, CompletionStage[])}
* <li>{@link #mostResultsOfSuccess(Object, Executor, long, TimeUnit, CompletionStage[])}
* <li>{@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)}
* <li>{@link #mostTupleOfSuccess(Executor, long, TimeUnit, CompletionStage, CompletionStage)}
* <li>{@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)}
Expand All @@ -304,7 +304,7 @@ private static <T> CompletableFuture<? extends T>[] wrapSuppliers(
* @see #allTupleOf(CompletionStage, CompletionStage)
* @see #allTupleOf(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
* @see #mostResultsOfSuccess(long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Executor, long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Object, Executor, long, TimeUnit, CompletionStage[])
* @see #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)
* @see #mostTupleOfSuccess(Executor, long, TimeUnit, CompletionStage, CompletionStage)
* @see #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
Expand Down Expand Up @@ -376,7 +376,7 @@ public static <T> CompletableFuture<List<T>> allResultsOf(CompletionStage<? exte
* If you need the successful results of given stages in the given time, prefer below methods:
* <ul>
* <li>{@link #mostResultsOfSuccess(long, TimeUnit, Object, CompletionStage[])}
* <li>{@link #mostResultsOfSuccess(Executor, long, TimeUnit, Object, CompletionStage[])}
* <li>{@link #mostResultsOfSuccess(Object, Executor, long, TimeUnit, CompletionStage[])}
* <li>{@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)}
* <li>{@link #mostTupleOfSuccess(Executor, long, TimeUnit, CompletionStage, CompletionStage)}
* <li>{@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)}
Expand All @@ -390,7 +390,7 @@ public static <T> CompletableFuture<List<T>> allResultsOf(CompletionStage<? exte
* @see #allTupleOfFastFail(CompletionStage, CompletionStage)
* @see #allTupleOfFastFail(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
* @see #mostResultsOfSuccess(long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Executor, long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Object, Executor, long, TimeUnit, CompletionStage[])
* @see #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)
* @see #mostTupleOfSuccess(Executor, long, TimeUnit, CompletionStage, CompletionStage)
* @see #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
Expand Down Expand Up @@ -477,7 +477,7 @@ public static <T> CompletableFuture<List<T>> allResultsOfFastFail(CompletionStag
@SafeVarargs
public static <T> CompletableFuture<List<T>> mostResultsOfSuccess(
long timeout, TimeUnit unit, @Nullable T valueIfNotSuccess, CompletionStage<? extends T>... cfs) {
return mostResultsOfSuccess(AsyncPoolHolder.ASYNC_POOL, timeout, unit, valueIfNotSuccess, cfs);
return mostResultsOfSuccess(valueIfNotSuccess, AsyncPoolHolder.ASYNC_POOL, timeout, unit, cfs);
}

/**
Expand All @@ -486,18 +486,18 @@ public static <T> CompletableFuture<List<T>> mostResultsOfSuccess(
* <p>
* If the given stage is successful, its result is the completed value; Otherwise the given valueIfNotSuccess.
*
* @param valueIfNotSuccess the value to return if not completed successfully
* @param executorWhenTimeout the async executor when triggered by timeout
* @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 valueIfNotSuccess the value to return if not completed successfully
* @param cfs the stages
* @see #getSuccessNow(CompletableFuture, Object)
*/
@Contract(pure = true)
@SafeVarargs
public static <T> CompletableFuture<List<T>> mostResultsOfSuccess(
Executor executorWhenTimeout, long timeout, TimeUnit unit,
@Nullable T valueIfNotSuccess, CompletionStage<? extends T>... cfs) {
@Nullable T valueIfNotSuccess, Executor executorWhenTimeout, long timeout, TimeUnit unit,
CompletionStage<? extends T>... cfs) {
requireNonNull(executorWhenTimeout, "executorWhenTimeout is null");
requireNonNull(unit, "unit is null");
requireNonNull(cfs, "cfs is null");
Expand Down Expand Up @@ -1341,7 +1341,7 @@ public static <T, U> CompletableFuture<List<U>> thenMApplyMostSuccessAsync(
requireArrayAndEleNonNull("fn", fns);

return toNonMinCf(cf).thenCompose(v -> mostResultsOfSuccess(
executor, timeout, unit, valueIfNotSuccess, wrapFunctions(executor, v, fns)
valueIfNotSuccess, executor, timeout, unit, wrapFunctions(executor, v, fns)
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ fun <T> Collection<CompletionStage<out T>>.mostResultsOfSuccessCompletableFuture
executorWhenTimeout: Executor, timeout: Long, unit: TimeUnit, valueIfNotSuccess: T
): CompletableFuture<List<T>> =
CompletableFutureUtils.mostResultsOfSuccess(
executorWhenTimeout, timeout, unit, valueIfNotSuccess, *toTypedArray()
valueIfNotSuccess, executorWhenTimeout, timeout, unit, *toTypedArray()
)

/**
Expand All @@ -244,7 +244,7 @@ fun <T> Collection<CompletionStage<out T>>.mostResultsOfSuccessCompletableFuture
fun <T> Array<out CompletionStage<out T>>.mostResultsOfSuccessCompletableFuture(
executorWhenTimeout: Executor, timeout: Long, unit: TimeUnit, valueIfNotSuccess: T
): CompletableFuture<List<T>> =
CompletableFutureUtils.mostResultsOfSuccess(executorWhenTimeout, timeout, unit, valueIfNotSuccess, *this)
CompletableFutureUtils.mostResultsOfSuccess(valueIfNotSuccess, executorWhenTimeout, timeout, unit, *this)

////////////////////////////////////////
//# anyOf* methods for Array/Collection
Expand Down

0 comments on commit ec5604e

Please sign in to comment.