Skip to content

Commit

Permalink
chore: update after release v1.0.0-Alpha20 📦
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Aug 24, 2024
1 parent 3b10cc3 commit e587e57
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 74 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/Java-8+-339933?logo=openjdk&logoColor=white" alt="Java support"></a>
<a href="https://kotlinlang.org"><img src="https://img.shields.io/badge/Kotlin-1.6+-7F52FF.svg?logo=kotlin&logoColor=white" alt="Kotlin"></a>
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/foldright/cffu?color=4D7A97&logo=apache" alt="License"></a>
<a href="https://foldright.io/api-docs/cffu/"><img src="https://img.shields.io/github/release/foldright/cffu?label=javadoc&color=339933&logo=microsoft-academic&logoColor=white" alt="Javadocs"></a>
<a href="https://foldright.io/api-docs/cffu/"><img src="https://img.shields.io/github/release/foldright/cffu?label=javadoc&color=339933&logo=read-the-docs&logoColor=white" alt="Javadocs"></a>
<a href="https://foldright.io/api-docs/cffu-kotlin/"><img src="https://img.shields.io/github/release/foldright/cffu?label=dokka&color=339933&logo=kotlin&logoColor=white" alt="dokka"></a>
<a href="https://central.sonatype.com/artifact/io.foldright/cffu/0.9.0/versions"><img src="https://img.shields.io/maven-central/v/io.foldright/cffu?logo=apache-maven&logoColor=white" alt="Maven Central"></a>
<a href="https://github.com/foldright/cffu/releases"><img src="https://img.shields.io/github/release/foldright/cffu.svg" alt="GitHub Releases"></a>
Expand Down Expand Up @@ -610,18 +610,18 @@ public class ConcurrencyStrategyDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu</artifactId>
<version>1.0.0-Alpha19</version>
<version>1.0.0-Alpha20</version>
</dependency>
```
- For `Gradle` projects:

```groovy
// Gradle Kotlin DSL
implementation("io.foldright:cffu:1.0.0-Alpha19")
implementation("io.foldright:cffu:1.0.0-Alpha20")
```
```groovy
// Gradle Groovy DSL
implementation 'io.foldright:cffu:1.0.0-Alpha19'
implementation 'io.foldright:cffu:1.0.0-Alpha20'
```
- `cffu Kotlin`支持库:
- For `Maven` projects:
Expand All @@ -630,18 +630,18 @@ public class ConcurrencyStrategyDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-kotlin</artifactId>
<version>1.0.0-Alpha19</version>
<version>1.0.0-Alpha20</version>
</dependency>
```
- For `Gradle` projects:

```groovy
// Gradle Kotlin DSL
implementation("io.foldright:cffu-kotlin:1.0.0-Alpha19")
implementation("io.foldright:cffu-kotlin:1.0.0-Alpha20")
```
```groovy
// Gradle Groovy DSL
implementation 'io.foldright:cffu-kotlin:1.0.0-Alpha19'
implementation 'io.foldright:cffu-kotlin:1.0.0-Alpha20'
```
- `cffu bom`:
- For `Maven` projects:
Expand All @@ -650,7 +650,7 @@ public class ConcurrencyStrategyDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-bom</artifactId>
<version>1.0.0-Alpha19</version>
<version>1.0.0-Alpha20</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -659,11 +659,11 @@ public class ConcurrencyStrategyDemo {

```groovy
// Gradle Kotlin DSL
implementation(platform("io.foldright:cffu-bom:1.0.0-Alpha19"))
implementation(platform("io.foldright:cffu-bom:1.0.0-Alpha20"))
```
```groovy
// Gradle Groovy DSL
implementation platform('io.foldright:cffu-bom:1.0.0-Alpha19')
implementation platform('io.foldright:cffu-bom:1.0.0-Alpha20')
```
- [📌 `TransmittableThreadLocal(TTL)`](https://github.com/alibaba/transmittable-thread-local)的[`cffu executor wrapper SPI`实现](cffu-ttl-executor-wrapper):
- For `Maven` projects:
Expand All @@ -672,19 +672,19 @@ public class ConcurrencyStrategyDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-ttl-executor-wrapper</artifactId>
<version>1.0.0-Alpha19</version>
<version>1.0.0-Alpha20</version>
<scope>runtime</scope>
</dependency>
```
- For `Gradle` projects:

```groovy
// Gradle Kotlin DSL
runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha19")
runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha20")
```
```groovy
// Gradle Groovy DSL
runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha19'
runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha20'
```

# 📚 更多资料
Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/Java-8+-339933?logo=openjdk&logoColor=white" alt="Java support"></a>
<a href="https://kotlinlang.org"><img src="https://img.shields.io/badge/Kotlin-1.6+-7F52FF.svg?logo=kotlin&logoColor=white" alt="Kotlin"></a>
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/foldright/cffu?color=4D7A97&logo=apache" alt="License"></a>
<a href="https://foldright.io/api-docs/cffu/"><img src="https://img.shields.io/github/release/foldright/cffu?label=javadoc&color=339933&logo=microsoft-academic&logoColor=white" alt="Javadocs"></a>
<a href="https://foldright.io/api-docs/cffu/"><img src="https://img.shields.io/github/release/foldright/cffu?label=javadoc&color=339933&logo=read-the-docs&logoColor=white" alt="Javadocs"></a>
<a href="https://foldright.io/api-docs/cffu-kotlin/"><img src="https://img.shields.io/github/release/foldright/cffu?label=dokka&color=339933&logo=kotlin&logoColor=white" alt="dokka"></a>
<a href="https://central.sonatype.com/artifact/io.foldright/cffu/0.9.0/versions"><img src="https://img.shields.io/maven-central/v/io.foldright/cffu?logo=apache-maven&logoColor=white" alt="Maven Central"></a>
<a href="https://github.com/foldright/cffu/releases"><img src="https://img.shields.io/github/release/foldright/cffu.svg" alt="GitHub Releases"></a>
Expand Down
65 changes: 28 additions & 37 deletions cffu-core/src/main/java/io/foldright/cffu/Cffu.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.foldright.cffu;

import com.google.common.util.concurrent.AsyncFunction;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
import edu.umd.cs.findbugs.annotations.Nullable;
Expand Down Expand Up @@ -211,6 +213,10 @@ public Cffu<Void> thenRunAsync(Runnable action, Executor executor) {
// endregion
////////////////////////////////////////////////////////////
// region# Then-Multi-Actions(thenM*) Methods
//
// - thenMApply*: Function<U>[] -> Cffu<List<U>>
// - thenMAccept*: Consumer[] -> Cffu<Void>
// - thenMRun*: Runnable[] -> Cffu<Void>
////////////////////////////////////////////////////////////

/**
Expand Down Expand Up @@ -1163,9 +1169,8 @@ public <U, V> Cffu<V> thenCombineFastFailAsync(
* @return the new Cffu
*/
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `thenAcceptBothFastFailAsync`")
public <U, V> Cffu<V> thenCombineFastFailAsync(CompletionStage<? extends U> other,
BiFunction<? super T, ? super U, ? extends V> fn,
Executor executor) {
public <U, V> Cffu<V> thenCombineFastFailAsync(
CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) {
return reset0(CompletableFutureUtils.thenCombineFastFailAsync(cf, other, fn, executor));
}

Expand Down Expand Up @@ -1216,9 +1221,8 @@ public <U> Cffu<Void> thenAcceptBothFastFailAsync(
* @param <U> the type of the other CompletionStage's result
* @return the new Cffu
*/
public <U> Cffu<Void> thenAcceptBothFastFailAsync(CompletionStage<? extends U> other,
BiConsumer<? super T, ? super U> action,
Executor executor) {
public <U> Cffu<Void> thenAcceptBothFastFailAsync(
CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) {
return reset0(CompletableFutureUtils.thenAcceptBothFastFailAsync(cf, other, action, executor));
}

Expand Down Expand Up @@ -1320,9 +1324,8 @@ public <U, V> Cffu<V> thenCombineAsync(
*/
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `thenAcceptBothAsync`")
@Override
public <U, V> Cffu<V> thenCombineAsync(CompletionStage<? extends U> other,
BiFunction<? super T, ? super U, ? extends V> fn,
Executor executor) {
public <U, V> Cffu<V> thenCombineAsync(
CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) {
return reset0(cf.thenCombineAsync(other, fn, executor));
}

Expand Down Expand Up @@ -1374,9 +1377,8 @@ public <U> Cffu<Void> thenAcceptBothAsync(
* @return the new Cffu
*/
@Override
public <U> Cffu<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
BiConsumer<? super T, ? super U> action,
Executor executor) {
public <U> Cffu<Void> thenAcceptBothAsync(
CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) {
return reset0(cf.thenAcceptBothAsync(other, action, executor));
}

Expand Down Expand Up @@ -1477,9 +1479,8 @@ public <U> Cffu<U> applyToEitherSuccessAsync(
* @return the new Cffu
*/
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `acceptEitherSuccessAsync`")
public <U> Cffu<U> applyToEitherSuccessAsync(CompletionStage<? extends T> other,
Function<? super T, U> fn,
Executor executor) {
public <U> Cffu<U> applyToEitherSuccessAsync(
CompletionStage<? extends T> other, Function<? super T, U> fn, Executor executor) {
return reset0(CompletableFutureUtils.applyToEitherSuccessAsync(cf, other, fn, executor));
}

Expand Down Expand Up @@ -1519,9 +1520,8 @@ public Cffu<Void> acceptEitherSuccessAsync(
* @param executor the executor to use for asynchronous execution
* @return the new Cffu
*/
public Cffu<Void> acceptEitherSuccessAsync(CompletionStage<? extends T> other,
Consumer<? super T> action,
Executor executor) {
public Cffu<Void> acceptEitherSuccessAsync(
CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) {
return reset0(CompletableFutureUtils.acceptEitherSuccessAsync(cf, other, action, executor));
}

Expand Down Expand Up @@ -1619,9 +1619,8 @@ public <U> Cffu<U> applyToEitherAsync(
*/
@CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `acceptEitherAsync`")
@Override
public <U> Cffu<U> applyToEitherAsync(CompletionStage<? extends T> other,
Function<? super T, U> fn,
Executor executor) {
public <U> Cffu<U> applyToEitherAsync(
CompletionStage<? extends T> other, Function<? super T, U> fn, Executor executor) {
return reset0(cf.applyToEitherAsync(other, fn, executor));
}

Expand Down Expand Up @@ -1670,9 +1669,8 @@ public Cffu<Void> acceptEitherAsync(
* @return the new Cffu
*/
@Override
public Cffu<Void> acceptEitherAsync(CompletionStage<? extends T> other,
Consumer<? super T> action,
Executor executor) {
public Cffu<Void> acceptEitherAsync(
CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) {
return reset0(cf.acceptEitherAsync(other, action, executor));
}

Expand Down Expand Up @@ -1738,7 +1736,7 @@ public Cffu<Void> runAfterEitherAsync(
* callers should prefer more specific types, avoiding {@code Throwable.class} in particular.
* @param fallback the Function to be called if {@code input} fails with the expected exception type.
* The function's argument is the input's exception.
* @see com.google.common.util.concurrent.Futures#catching(ListenableFuture, Class, com.google.common.base.Function, Executor) Guava method catching()
* @see Futures#catching(ListenableFuture, Class, com.google.common.base.Function, Executor) Guava method catching()
*/
public <X extends Throwable> Cffu<T> catching(Class<X> exceptionType, Function<? super X, ? extends T> fallback) {
return reset0(CompletableFutureUtils.catching(cf, exceptionType, fallback));
Expand All @@ -1755,7 +1753,7 @@ public <X extends Throwable> Cffu<T> catching(Class<X> exceptionType, Function<?
* callers should prefer more specific types, avoiding {@code Throwable.class} in particular.
* @param fallback the Function to be called if {@code input} fails with the expected exception type.
* The function's argument is the input's exception.
* @see com.google.common.util.concurrent.Futures#catching(ListenableFuture, Class, com.google.common.base.Function, Executor) Guava method catching()
* @see Futures#catching(ListenableFuture, Class, com.google.common.base.Function, Executor) Guava method catching()
*/
public <X extends Throwable> Cffu<T> catchingAsync(
Class<X> exceptionType, Function<? super X, ? extends T> fallback) {
Expand All @@ -1773,7 +1771,7 @@ public <X extends Throwable> Cffu<T> catchingAsync(
* @param fallback the Function to be called if {@code input} fails with the expected exception type.
* The function's argument is the input's exception.
* @param executor the executor to use for asynchronous execution
* @see com.google.common.util.concurrent.Futures#catching(ListenableFuture, Class, com.google.common.base.Function, Executor) Guava method catching()
* @see Futures#catching(ListenableFuture, Class, com.google.common.base.Function, Executor) Guava method catching()
*/
public <X extends Throwable> Cffu<T> catchingAsync(
Class<X> exceptionType, Function<? super X, ? extends T> fallback, Executor executor) {
Expand Down Expand Up @@ -1971,13 +1969,6 @@ public Cffu<T> unsafeCompleteOnTimeout(@Nullable T value, long timeout, TimeUnit
////////////////////////////////////////////////////////////////////////////////
// region# Advanced Methods(compose* and handle-like methods)
//
// - thenCompose*: T -> CompletionStage<T>
// - exceptionallyCompose*: throwable -> CompletionStage<T>
//
// - handle*: (T, throwable) -> U
// - whenComplete*: (T, throwable) -> Void
// - peek*: (T, throwable) -> Void
//
// NOTE about advanced meaning:
// - `compose` methods, input function argument return CompletionStage
// - handle successful and failed result together(handle*/whenComplete*/peek*)
Expand Down Expand Up @@ -2061,7 +2052,7 @@ public <U> Cffu<U> thenComposeAsync(
* callers should prefer more specific types, avoiding {@code Throwable.class} in particular.
* @param fallback the Function to be called if {@code input} fails with the expected exception type.
* The function's argument is the input's exception.
* @see com.google.common.util.concurrent.Futures#catchingAsync(ListenableFuture, Class, com.google.common.util.concurrent.AsyncFunction, Executor) Guava method catchingAsync()
* @see Futures#catchingAsync(ListenableFuture, Class, AsyncFunction, Executor) Guava method catchingAsync()
*/
public <X extends Throwable> Cffu<T> catchingCompose(
Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> fallback) {
Expand All @@ -2078,7 +2069,7 @@ public <X extends Throwable> Cffu<T> catchingCompose(
* callers should prefer more specific types, avoiding {@code Throwable.class} in particular.
* @param fallback the Function to be called if {@code input} fails with the expected exception type.
* The function's argument is the input's exception.
* @see com.google.common.util.concurrent.Futures#catchingAsync(ListenableFuture, Class, com.google.common.util.concurrent.AsyncFunction, Executor) Guava method catchingAsync()
* @see Futures#catchingAsync(ListenableFuture, Class, AsyncFunction, Executor) Guava method catchingAsync()
*/
public <X extends Throwable> Cffu<T> catchingComposeAsync(
Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> fallback) {
Expand All @@ -2096,7 +2087,7 @@ public <X extends Throwable> Cffu<T> catchingComposeAsync(
* @param fallback the Function to be called if {@code input} fails with the expected exception type.
* The function's argument is the input's exception.
* @param executor the executor to use for asynchronous execution
* @see com.google.common.util.concurrent.Futures#catchingAsync(ListenableFuture, Class, com.google.common.util.concurrent.AsyncFunction, Executor) Guava method catchingAsync()
* @see Futures#catchingAsync(ListenableFuture, Class, AsyncFunction, Executor) Guava method catchingAsync()
*/
public <X extends Throwable> Cffu<T> catchingComposeAsync(
Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> fallback, Executor executor) {
Expand Down
Loading

0 comments on commit e587e57

Please sign in to comment.