Skip to content

Commit

Permalink
! update after release v1.0.0-Alpha3
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed May 5, 2024
1 parent 77dbddc commit dc7a409
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 42 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,18 +561,18 @@ public class ConcurrencyStrategyDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu</artifactId>
<version>1.0.0-Alpha2</version>
<version>1.0.0-Alpha3</version>
</dependency>
```
- 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:
Expand All @@ -581,18 +581,18 @@ public class ConcurrencyStrategyDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-kotlin</artifactId>
<version>1.0.0-Alpha2</version>
<version>1.0.0-Alpha3</version>
</dependency>
```
- 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:
Expand All @@ -601,7 +601,7 @@ public class ConcurrencyStrategyDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-bom</artifactId>
<version>1.0.0-Alpha2</version>
<version>1.0.0-Alpha3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -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:
Expand All @@ -623,19 +623,19 @@ public class ConcurrencyStrategyDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-ttl-executor-wrapper</artifactId>
<version>1.0.0-Alpha2</version>
<version>1.0.0-Alpha3</version>
<scope>runtime</scope>
</dependency>
```
- 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'
```

# 📚 更多资料
Expand Down
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 @@ -632,7 +632,7 @@ public Executor delayedExecutor(long delay, TimeUnit unit, Executor executor) {
}

////////////////////////////////////////////////////////////////////////////////
//# Conversion Methods
//# Conversion (Static) Methods
//
// - cffuListToArray: List<Cffu> -> Cffu[]
// - completableFutureListToArray: List<CF> -> CF[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.function.*;

import static java.util.Objects.requireNonNull;
import static java.util.function.Function.identity;


/**
Expand Down Expand Up @@ -464,8 +463,8 @@ public static <T1, T2, T3, T4> CompletableFuture<Tuple4<T1, T2, T3, T4>> allTupl
@Contract(pure = true)
@SuppressWarnings("unchecked")
public static <T1, T2, T3, T4, T5> CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> allTupleOf(
CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2,
CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) {
CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3,
CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) {
final CompletionStage<?>[] css = requireCfsAndEleNonNull(cf1, cf2, cf3, cf4, cf5);

final Object[] result = new Object[css.length];
Expand All @@ -492,8 +491,8 @@ public static <T1, T2, T3, T4, T5> CompletableFuture<Tuple5<T1, T2, T3, T4, T5>>
@Contract(pure = true)
@SuppressWarnings("unchecked")
public static <T1, T2, T3, T4, T5> CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> allTupleOfFastFail(
CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2,
CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) {
CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3,
CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) {
final CompletionStage<?>[] css = requireCfsAndEleNonNull(cf1, cf2, cf3, cf4, cf5);

final Object[] result = new Object[css.length];
Expand Down Expand Up @@ -707,8 +706,7 @@ public static <T, U, V> CompletableFuture<V> thenCombineFastFail(
@SuppressWarnings("unchecked")
public static <T, U, V> CompletableFuture<V> thenCombineFastFailAsync(
CompletionStage<? extends T> cf1, CompletionStage<? extends U> cf2,
BiFunction<? super T, ? super U, ? extends V> fn
) {
BiFunction<? super T, ? super U, ? extends V> fn) {
final CompletionStage<?>[] css = requireCfsAndEleNonNull(cf1, cf2);
requireNonNull(fn, "fn is null");

Expand Down Expand Up @@ -736,8 +734,7 @@ public static <T, U, V> CompletableFuture<V> thenCombineFastFailAsync(
@SuppressWarnings("unchecked")
public static <T, U, V> CompletableFuture<V> thenCombineFastFailAsync(
CompletionStage<? extends T> cf1, CompletionStage<? extends U> cf2,
BiFunction<? super T, ? super U, ? extends V> fn, Executor executor
) {
BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) {
final CompletionStage<?>[] css = requireCfsAndEleNonNull(cf1, cf2);
requireNonNull(fn, "fn is null");
requireNonNull(executor, "executor is null");
Expand Down Expand Up @@ -1156,13 +1153,12 @@ public static <T> CompletableFuture<T> 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.<T>handleAsync((r1, ex1) -> fn.apply(ex1), executor)
).thenCompose(identity());
).thenCompose(x -> x);
}

//# Timeout Control methods
Expand Down Expand Up @@ -1197,8 +1193,8 @@ public static <C extends CompletableFuture<?>> 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 <T, C extends CompletableFuture<? super T>> C completeOnTimeout(
C cf, @Nullable T value, long timeout, TimeUnit unit) {
public static <T, C extends CompletableFuture<? super T>>
C completeOnTimeout(C cf, @Nullable T value, long timeout, TimeUnit unit) {
if (IS_JAVA9_PLUS) {
cf.completeOnTimeout(value, timeout, unit);
} else {
Expand Down Expand Up @@ -1229,7 +1225,7 @@ public static <T> CompletableFuture<T> 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);
}

/**
Expand Down Expand Up @@ -1264,8 +1260,8 @@ public static <T> CompletableFuture<T> 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
Expand Down Expand Up @@ -1445,8 +1441,8 @@ public static <T, C extends CompletableFuture<? super T>> C completeAsync(C cf,
* @param executor the executor to use for asynchronous execution
* @return given CompletableFuture
*/
public static <T, C extends CompletableFuture<? super T>> C completeAsync(
C cf, Supplier<? extends T> supplier, Executor executor) {
public static <T, C extends CompletableFuture<? super T>>
C completeAsync(C cf, Supplier<? extends T> supplier, Executor executor) {
if (IS_JAVA9_PLUS) {
cf.completeAsync(supplier, executor);
} else {
Expand Down Expand Up @@ -1477,7 +1473,7 @@ public static <T> CompletionStage<T> minimalCompletionStage(CompletableFuture<T>
if (IS_JAVA9_PLUS) {
return cf.minimalCompletionStage();
}
return cf.thenApply(identity());
return cf.thenApply(x -> x);
}

/**
Expand All @@ -1494,7 +1490,7 @@ public static <T> CompletableFuture<T> copy(CompletableFuture<T> cf) {
if (IS_JAVA9_PLUS) {
return cf.copy();
}
return cf.thenApply(identity());
return cf.thenApply(x -> x);
}

/**
Expand Down Expand Up @@ -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()
Expand All @@ -1556,12 +1551,15 @@ public static <T> CompletableFuture<T>[] 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 <T> CompletableFuture<T>[] completableFutureListToArray(List<CompletableFuture<T>> cfList) {
@SuppressWarnings("unchecked")
final CompletableFuture<T>[] a = new CompletableFuture[0];
final CompletableFuture<T>[] a = new CompletableFuture[cfList.size()];
return cfList.toArray(a);
}

Expand Down
6 changes: 3 additions & 3 deletions cffu-ttl-executor-wrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ For `Maven` projects:
<groupId>io.foldright</groupId>
<artifactId>cffu-ttl-executor-wrapper</artifactId>
<scope>runtime</scope>
<version>1.0.0-Alpha2</version>
<version>1.0.0-Alpha3</version>
</dependency>
```

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
Expand Down

0 comments on commit dc7a409

Please sign in to comment.