Skip to content

Commit

Permalink
CffuFactory新增tupleMSupplyMostSuccessAsync方法实现
Browse files Browse the repository at this point in the history
  • Loading branch information
huhaosumail committed Jun 24, 2024
1 parent 7a474ee commit b5f0848
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 59 deletions.
60 changes: 60 additions & 0 deletions cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,66 @@ public <T1, T2, T3, T4, T5> Cffu<Tuple5<T1, T2, T3, T4, T5>> tupleMSupplyFastFai
return create(CompletableFutureUtils.tupleMSupplyFastFailAsync(supplier1, supplier2, supplier3, supplier4, supplier5));
}

/**
* Returns a new Cffu that is asynchronously completed
* by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers
* in the <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior.
*
* @return the new Cffu
*/
@Contract(pure = true)
public <T1,T2> Cffu<Tuple2<T1,T2>> tupleMSupplyMostSuccessAsync(
long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) {
return create(CompletableFutureUtils.tupleMSupplyMostSuccessAsync(defaultExecutor, timeout, unit,supplier1, supplier2));
}

/**
* Returns a new Cffu that is asynchronously completed
* by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers
* in the <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior.
*
* @return the new Cffu
*/
@Contract(pure = true)
public <T1,T2,T3> Cffu<Tuple3<T1,T2,T3>> tupleMSupplyMostSuccessAsync(
long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) {
return create(CompletableFutureUtils.tupleMSupplyMostSuccessAsync(defaultExecutor, timeout, unit,supplier1,supplier2,supplier3));
}

/**
* Returns a new Cffu that is asynchronously completed
* by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers
* in the <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior.
*
* @return the new Cffu
*/
@Contract(pure = true)
public <T1,T2,T3,T4> Cffu<Tuple4<T1,T2,T3,T4>> tupleMSupplyMostSuccessAsync(
long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) {
return create(CompletableFutureUtils.tupleMSupplyMostSuccessAsync(defaultExecutor, timeout, unit,supplier1,supplier2,supplier3,supplier4));
}

/**
* Returns a new Cffu that is asynchronously completed
* by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers
* in the <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior.
*
* @return the new Cffu
*/
@Contract(pure = true)
public <T1,T2,T3,T4,T5> Cffu<Tuple5<T1,T2,T3,T4,T5>> tupleMSupplyMostSuccessAsync(
long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) {
return create(CompletableFutureUtils.tupleMSupplyMostSuccessAsync(defaultExecutor, timeout, unit,supplier1,supplier2,supplier3,supplier4,supplier5));
}

/**
* Returns a new Cffu that is asynchronously completed
* by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,19 @@ public static <T> CompletableFuture<List<T>> mSupplyMostSuccessAsync(
}


/**
* Returns a new CompletableFuture that is asynchronously completed
* by tasks running in the given Executor with the values obtained by calling the given Suppliers
* in the <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior.
*
* @return the new CompletableFuture
*/
public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyMostSuccessAsync(
long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) {
return tupleMSupplyMostSuccessAsync(AsyncPoolHolder.ASYNC_POOL, timeout, unit, supplier1,supplier2);
}
// /**
// * Returns a new CompletableFuture that is asynchronously completed
// * by tasks running in the given Executor with the values obtained by calling the given Suppliers
// * in the <strong>same order</strong> of the given Suppliers arguments.
// * <p>
// * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior.
// *
// * @return the new CompletableFuture
// */
// public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyMostSuccessAsync(
// long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) {
// return tupleMSupplyMostSuccessAsync(AsyncPoolHolder.ASYNC_POOL, timeout, unit, supplier1,supplier2);
// }

/**
* Returns a new CompletableFuture that is asynchronously completed
Expand Down Expand Up @@ -313,24 +313,6 @@ public static <T,U1,U2,U3,U4,U5> CompletableFuture<Tuple5<U1,U2,U3,U4,U5>> tuple
}






/**
* Returns a new CompletableFuture that is asynchronously completed
* by tasks running in the given Executor with the values obtained by calling the given Suppliers
* in the <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier,Supplier)} except for the most-success behavior.
*
* @return the new CompletableFuture
*/
public static <T1,T2,T3> CompletableFuture<Tuple3<T1,T2,T3>> tupleMSupplyMostSuccessAsync(
long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) {
return tupleMSupplyMostSuccessAsync(AsyncPoolHolder.ASYNC_POOL, timeout, unit, supplier1,supplier2,supplier3);
}

/**
* Returns a new CompletableFuture that is asynchronously completed
* by tasks running in the given Executor with the values obtained by calling the given Suppliers
Expand All @@ -355,20 +337,6 @@ public static <T1,T2,T3> CompletableFuture<Tuple3<T1,T2,T3>> tupleMSupplyMostSuc
}


/**
* Returns a new CompletableFuture that is asynchronously completed
* by tasks running in the given Executor with the values obtained by calling the given Suppliers
* in the <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier,Supplier,Supplier)} except for the most-success behavior.
*
* @return the new CompletableFuture
*/
public static <T1,T2,T3,T4> CompletableFuture<Tuple4<T1,T2,T3,T4>> tupleMSupplyMostSuccessAsync(
long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) {
return tupleMSupplyMostSuccessAsync(AsyncPoolHolder.ASYNC_POOL, timeout, unit, supplier1,supplier2,supplier3,supplier4);
}

/**
* Returns a new CompletableFuture that is asynchronously completed
* by tasks running in the given Executor with the values obtained by calling the given Suppliers
Expand All @@ -395,20 +363,6 @@ public static <T1,T2,T3,T4> CompletableFuture<Tuple4<T1,T2,T3,T4>> tupleMSupplyM
}


/**
* Returns a new CompletableFuture that is asynchronously completed
* by tasks running in the given Executor with the values obtained by calling the given Suppliers
* in the <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier,Supplier,Supplier,Supplier)} except for the most-success behavior.
*
* @return the new CompletableFuture
*/
public static <T1,T2,T3,T4,T5> CompletableFuture<Tuple5<T1,T2,T3,T4,T5>> tupleMSupplyMostSuccessAsync(
long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) {
return tupleMSupplyMostSuccessAsync(AsyncPoolHolder.ASYNC_POOL, timeout, unit, supplier1,supplier2,supplier3,supplier4,supplier5);
}

/**
* Returns a new CompletableFuture that is asynchronously completed
* by tasks running in the given Executor with the values obtained by calling the given Suppliers
Expand Down

0 comments on commit b5f0848

Please sign in to comment.