From e06525c406da69f29c86cbb9da6bfdf415711e76 Mon Sep 17 00:00:00 2001 From: huhaosumail <995483610@qq.com> Date: Mon, 24 Jun 2024 20:55:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=96=B9=E6=B3=95=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cffu/CompletableFutureUtils.java | 158 +++++++++--------- 1 file changed, 80 insertions(+), 78 deletions(-) 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 37a1c166..36610fec 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -133,84 +133,6 @@ public static CompletableFuture> 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 same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier)} except for the most-success behavior. - * - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public static CompletableFuture> tupleMSupplyMostSuccessAsync( - Executor executor, long timeout, TimeUnit unit, Supplier supplier1, Supplier supplier2) { - requireNonNull(executor, "executor is null"); - requireNonNull(unit, "unit is null"); - Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2); - - return mostTupleOfSuccess0(executor,timeout, unit, wrapSuppliers(executor,suppliers)); - } - - /** - * 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 same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier,Supplier)} except for the most-success behavior. - * - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public static CompletableFuture> tupleMSupplyMostSuccessAsync( - Executor executor, long timeout, TimeUnit unit, Supplier supplier1, Supplier supplier2, Supplier supplier3) { - requireNonNull(executor, "executor is null"); - requireNonNull(unit, "unit is null"); - Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2,supplier3); - - return mostTupleOfSuccess0(executor,timeout, unit, wrapSuppliers(executor,suppliers)); - } - - - /** - * 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 same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier,Supplier,Supplier)} except for the most-success behavior. - * - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public static CompletableFuture> tupleMSupplyMostSuccessAsync( - Executor executor, long timeout, TimeUnit unit, Supplier supplier1, Supplier supplier2, Supplier supplier3, Supplier supplier4) { - requireNonNull(executor, "executor is null"); - requireNonNull(unit, "unit is null"); - Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2,supplier3,supplier4); - - return mostTupleOfSuccess0(executor,timeout, unit, wrapSuppliers(executor,suppliers)); - } - - - /** - * 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 same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier,Supplier,Supplier,Supplier)} except for the most-success behavior. - * - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public static CompletableFuture> tupleMSupplyMostSuccessAsync( - Executor executor, long timeout, TimeUnit unit, Supplier supplier1, Supplier supplier2, Supplier supplier3, Supplier supplier4, Supplier supplier5) { - requireNonNull(executor, "executor is null"); - requireNonNull(unit, "unit is null"); - Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2,supplier3,supplier4,supplier5); - - return mostTupleOfSuccess0(executor,timeout, unit, wrapSuppliers(executor,suppliers)); - } - /** * Returns a new CompletableFuture that is asynchronously completed @@ -640,6 +562,86 @@ public static CompletableFuture> return allTupleOf0(false, wrapSuppliers(executor, suppliers)); } + + /** + * 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 same order of the given Suppliers arguments. + *

+ * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier)} except for the most-success behavior. + * + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public static CompletableFuture> tupleMSupplyMostSuccessAsync( + Executor executor, long timeout, TimeUnit unit, Supplier supplier1, Supplier supplier2) { + requireNonNull(executor, "executor is null"); + requireNonNull(unit, "unit is null"); + Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2); + + return mostTupleOfSuccess0(executor,timeout, unit, wrapSuppliers(executor,suppliers)); + } + + /** + * 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 same order of the given Suppliers arguments. + *

+ * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier,Supplier)} except for the most-success behavior. + * + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public static CompletableFuture> tupleMSupplyMostSuccessAsync( + Executor executor, long timeout, TimeUnit unit, Supplier supplier1, Supplier supplier2, Supplier supplier3) { + requireNonNull(executor, "executor is null"); + requireNonNull(unit, "unit is null"); + Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2,supplier3); + + return mostTupleOfSuccess0(executor,timeout, unit, wrapSuppliers(executor,suppliers)); + } + + + /** + * 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 same order of the given Suppliers arguments. + *

+ * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier,Supplier,Supplier)} except for the most-success behavior. + * + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public static CompletableFuture> tupleMSupplyMostSuccessAsync( + Executor executor, long timeout, TimeUnit unit, Supplier supplier1, Supplier supplier2, Supplier supplier3, Supplier supplier4) { + requireNonNull(executor, "executor is null"); + requireNonNull(unit, "unit is null"); + Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2,supplier3,supplier4); + + return mostTupleOfSuccess0(executor,timeout, unit, wrapSuppliers(executor,suppliers)); + } + + + /** + * 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 same order of the given Suppliers arguments. + *

+ * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier,Supplier,Supplier,Supplier)} except for the most-success behavior. + * + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public static CompletableFuture> tupleMSupplyMostSuccessAsync( + Executor executor, long timeout, TimeUnit unit, Supplier supplier1, Supplier supplier2, Supplier supplier3, Supplier supplier4, Supplier supplier5) { + requireNonNull(executor, "executor is null"); + requireNonNull(unit, "unit is null"); + Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2,supplier3,supplier4,supplier5); + + return mostTupleOfSuccess0(executor,timeout, unit, wrapSuppliers(executor,suppliers)); + } + + // endregion //////////////////////////////////////////////////////////// // region## allOf* Methods(including mostResultsOfSuccess)