From dc7a409a5549a5240cde9836c4f58aaf256f7943 Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Thu, 2 May 2024 19:55:55 +0800 Subject: [PATCH] ! update after release `v1.0.0-Alpha3` --- README.md | 24 ++++----- .../java/io/foldright/cffu/CffuFactory.java | 2 +- .../cffu/CompletableFutureUtils.java | 50 +++++++++---------- cffu-ttl-executor-wrapper/README.md | 6 +-- 4 files changed, 40 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 4440de8c..076f9423 100644 --- a/README.md +++ b/README.md @@ -561,18 +561,18 @@ public class ConcurrencyStrategyDemo { io.foldright cffu - 1.0.0-Alpha2 + 1.0.0-Alpha3 ``` - For `Gradle` projects: ```groovy // Gradle Kotlin DSL - implementation("io.foldright:cffu:1.0.0-Alpha2") + implementation("io.foldright:cffu:1.0.0-Alpha3") ``` ```groovy // Gradle Groovy DSL - implementation 'io.foldright:cffu:1.0.0-Alpha2' + implementation 'io.foldright:cffu:1.0.0-Alpha3' ``` - `cffu Kotlin`支持库: - For `Maven` projects: @@ -581,18 +581,18 @@ public class ConcurrencyStrategyDemo { io.foldright cffu-kotlin - 1.0.0-Alpha2 + 1.0.0-Alpha3 ``` - For `Gradle` projects: ```groovy // Gradle Kotlin DSL - implementation("io.foldright:cffu-kotlin:1.0.0-Alpha2") + implementation("io.foldright:cffu-kotlin:1.0.0-Alpha3") ``` ```groovy // Gradle Groovy DSL - implementation 'io.foldright:cffu-kotlin:1.0.0-Alpha2' + implementation 'io.foldright:cffu-kotlin:1.0.0-Alpha3' ``` - `cffu bom`: - For `Maven` projects: @@ -601,7 +601,7 @@ public class ConcurrencyStrategyDemo { io.foldright cffu-bom - 1.0.0-Alpha2 + 1.0.0-Alpha3 pom import @@ -610,11 +610,11 @@ public class ConcurrencyStrategyDemo { ```groovy // Gradle Kotlin DSL - implementation(platform("io.foldright:cffu-bom:1.0.0-Alpha2")) + implementation(platform("io.foldright:cffu-bom:1.0.0-Alpha3")) ``` ```groovy // Gradle Groovy DSL - implementation platform('io.foldright:cffu-bom:1.0.0-Alpha2') + implementation platform('io.foldright:cffu-bom:1.0.0-Alpha3') ``` - [📌 `TransmittableThreadLocal(TTL)`](https://github.com/alibaba/transmittable-thread-local)的[`cffu executor wrapper SPI`实现](cffu-ttl-executor-wrapper): - For `Maven` projects: @@ -623,7 +623,7 @@ public class ConcurrencyStrategyDemo { io.foldright cffu-ttl-executor-wrapper - 1.0.0-Alpha2 + 1.0.0-Alpha3 runtime ``` @@ -631,11 +631,11 @@ public class ConcurrencyStrategyDemo { ```groovy // Gradle Kotlin DSL - runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha2") + runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha3") ``` ```groovy // Gradle Groovy DSL - runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha2' + runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha3' ``` # 📚 更多资料 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 fec9c41b..a115694a 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java @@ -632,7 +632,7 @@ public Executor delayedExecutor(long delay, TimeUnit unit, Executor executor) { } //////////////////////////////////////////////////////////////////////////////// - //# Conversion Methods + //# Conversion (Static) Methods // // - cffuListToArray: List -> Cffu[] // - completableFutureListToArray: List -> CF[] 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 5a288fb5..633a9319 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -17,7 +17,6 @@ import java.util.function.*; import static java.util.Objects.requireNonNull; -import static java.util.function.Function.identity; /** @@ -464,8 +463,8 @@ public static CompletableFuture> allTupl @Contract(pure = true) @SuppressWarnings("unchecked") public static CompletableFuture> allTupleOf( - CompletionStage cf1, CompletionStage cf2, - CompletionStage cf3, CompletionStage cf4, CompletionStage cf5) { + CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, + CompletionStage cf4, CompletionStage cf5) { final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2, cf3, cf4, cf5); final Object[] result = new Object[css.length]; @@ -492,8 +491,8 @@ public static CompletableFuture> @Contract(pure = true) @SuppressWarnings("unchecked") public static CompletableFuture> allTupleOfFastFail( - CompletionStage cf1, CompletionStage cf2, - CompletionStage cf3, CompletionStage cf4, CompletionStage cf5) { + CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, + CompletionStage cf4, CompletionStage cf5) { final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2, cf3, cf4, cf5); final Object[] result = new Object[css.length]; @@ -707,8 +706,7 @@ public static CompletableFuture thenCombineFastFail( @SuppressWarnings("unchecked") public static CompletableFuture thenCombineFastFailAsync( CompletionStage cf1, CompletionStage cf2, - BiFunction fn - ) { + BiFunction fn) { final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); requireNonNull(fn, "fn is null"); @@ -736,8 +734,7 @@ public static CompletableFuture thenCombineFastFailAsync( @SuppressWarnings("unchecked") public static CompletableFuture thenCombineFastFailAsync( CompletionStage cf1, CompletionStage cf2, - BiFunction fn, Executor executor - ) { + BiFunction fn, Executor executor) { final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); requireNonNull(fn, "fn is null"); requireNonNull(executor, "executor is null"); @@ -1156,13 +1153,12 @@ public static CompletableFuture exceptionallyAsync( if (IS_JAVA12_PLUS) { return cf.exceptionallyAsync(fn, executor); } - requireNonNull(fn, "fn is null"); requireNonNull(executor, "executor is null"); // below code is copied from CompletionStage#exceptionallyAsync return cf.handle((r, ex) -> (ex == null) ? cf : cf.handleAsync((r1, ex1) -> fn.apply(ex1), executor) - ).thenCompose(identity()); + ).thenCompose(x -> x); } //# Timeout Control methods @@ -1197,8 +1193,8 @@ public static > C orTimeout(C cf, long timeout, T * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return given CompletableFuture */ - public static > C completeOnTimeout( - C cf, @Nullable T value, long timeout, TimeUnit unit) { + public static > + C completeOnTimeout(C cf, @Nullable T value, long timeout, TimeUnit unit) { if (IS_JAVA9_PLUS) { cf.completeOnTimeout(value, timeout, unit); } else { @@ -1229,7 +1225,7 @@ public static CompletableFuture exceptionallyCompose( } requireNonNull(fn, "fn is null"); // below code is copied from CompletionStage.exceptionallyCompose - return cf.handle((r, ex) -> (ex == null) ? cf : fn.apply(ex)).thenCompose(identity()); + return cf.handle((r, ex) -> (ex == null) ? cf : fn.apply(ex)).thenCompose(x -> x); } /** @@ -1264,8 +1260,8 @@ public static CompletableFuture exceptionallyComposeAsync( requireNonNull(executor, "executor is null"); // below code is copied from CompletionStage.exceptionallyComposeAsync return cf.handle((r, ex) -> (ex == null) ? cf : - cf.handleAsync((r1, ex1) -> fn.apply(ex1), executor).thenCompose(identity()) - ).thenCompose(identity()); + cf.handleAsync((r1, ex1) -> fn.apply(ex1), executor).thenCompose(x -> x) + ).thenCompose(x -> x); } //# Read(explicitly) methods of CompletableFuture @@ -1445,8 +1441,8 @@ public static > C completeAsync(C cf, * @param executor the executor to use for asynchronous execution * @return given CompletableFuture */ - public static > C completeAsync( - C cf, Supplier supplier, Executor executor) { + public static > + C completeAsync(C cf, Supplier supplier, Executor executor) { if (IS_JAVA9_PLUS) { cf.completeAsync(supplier, executor); } else { @@ -1477,7 +1473,7 @@ public static CompletionStage minimalCompletionStage(CompletableFuture if (IS_JAVA9_PLUS) { return cf.minimalCompletionStage(); } - return cf.thenApply(identity()); + return cf.thenApply(x -> x); } /** @@ -1494,7 +1490,7 @@ public static CompletableFuture copy(CompletableFuture cf) { if (IS_JAVA9_PLUS) { return cf.copy(); } - return cf.thenApply(identity()); + return cf.thenApply(x -> x); } /** @@ -1527,16 +1523,15 @@ public static Executor defaultExecutor() { } //////////////////////////////////////////////////////////////////////////////// - //# Conversion (Static) Methods + //# Conversion Methods // // - toCompletableFutureArray: Cffu -> CF // - cffuArrayUnwrap: Cffu -> CF //////////////////////////////////////////////////////////////////////////////// /** - * A convenient util method for converting input {@link Cffu} / {@link CompletableFuture} / {@link CompletionStage} - * array element by {@link Cffu#toCompletableFuture()} / {@link CompletableFuture#toCompletableFuture()} / - * {@link CompletionStage#toCompletableFuture()}. + * A convenient util method for converting input {@link CompletionStage} (including + * {@link Cffu}/{@link CompletableFuture}) array element by {@link CompletionStage#toCompletableFuture()}. * * @see Cffu#toCompletableFuture() * @see CompletableFuture#toCompletableFuture() @@ -1556,12 +1551,15 @@ public static CompletableFuture[] toCompletableFutureArray(CompletionStag } /** - * Convert CompletableFuture list to CompletableFuture array. + * A convenient util method for converting input {@link CompletionStage} (including + * {@link Cffu}/{@link CompletableFuture}) list to CompletableFuture array. + * + * @see #toCompletableFutureArray(CompletionStage[]) */ @Contract(pure = true) public static CompletableFuture[] completableFutureListToArray(List> cfList) { @SuppressWarnings("unchecked") - final CompletableFuture[] a = new CompletableFuture[0]; + final CompletableFuture[] a = new CompletableFuture[cfList.size()]; return cfList.toArray(a); } diff --git a/cffu-ttl-executor-wrapper/README.md b/cffu-ttl-executor-wrapper/README.md index abc2cd9a..8fbcce53 100644 --- a/cffu-ttl-executor-wrapper/README.md +++ b/cffu-ttl-executor-wrapper/README.md @@ -18,7 +18,7 @@ For `Maven` projects: io.foldright cffu-ttl-executor-wrapper runtime - 1.0.0-Alpha2 + 1.0.0-Alpha3 ``` @@ -26,12 +26,12 @@ For `Gradle` projects: ```groovy // Gradle Kotlin DSL -runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha2") +runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha3") ``` ```groovy // Gradle Groovy DSL -runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha2' +runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha3' ``` `cffu-ttl-executor-wrapper` has published to maven central, find the latest version at