Skip to content

Commit

Permalink
fix wrong executor for Cffu.thenTupleM* methods 🐞 add new `Cffu.the…
Browse files Browse the repository at this point in the history
…nTupleM*` method with `executor` parameter 👯
  • Loading branch information
oldratlee committed Jun 24, 2024
1 parent 4892aa9 commit b4d19ce
Showing 1 changed file with 145 additions and 29 deletions.
174 changes: 145 additions & 29 deletions cffu-core/src/main/java/io/foldright/cffu/Cffu.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ public Cffu<Void> thenRunAsync(Runnable action, Executor executor) {
////////////////////////////////////////////////////////////

/**
* Returns a new Cffu that, when this Cffu completes normally,
* is executed using the {@link #defaultExecutor()},
* Returns a new Cffu that, when this Cffu completes normally, is executed using the {@link #defaultExecutor()},
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
Expand All @@ -230,12 +229,27 @@ public Cffu<Void> thenRunAsync(Runnable action, Executor executor) {
*/
public <U1, U2> Cffu<Tuple2<U1, U2>> thenTupleMApplyFastFailAsync(
Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) {
return reset0(CompletableFutureUtils.thenTupleMApplyFastFailAsync(cf, fn1, fn2));
return thenTupleMApplyFastFailAsync(fac.defaultExecutor(), fn1, fn2);
}

/**
* Returns a new Cffu that, when this Cffu completes normally,
* is executed using the {@link #defaultExecutor()},
* Returns a new Cffu that, when this Cffu completes normally, is executed using the supplied Executor,
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
* <p>
* This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function)}
* except for the fast-fail behavior.
*
* @return the new Cffu
*/
public <U1, U2> Cffu<Tuple2<U1, U2>> thenTupleMApplyFastFailAsync(
Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) {
return reset0(CompletableFutureUtils.thenTupleMApplyFastFailAsync(cf, executor, fn1, fn2));
}

/**
* Returns a new Cffu that, when this Cffu completes normally, is executed using the {@link #defaultExecutor()},
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
Expand All @@ -246,14 +260,30 @@ public <U1, U2> Cffu<Tuple2<U1, U2>> thenTupleMApplyFastFailAsync(
* @return the new Cffu
*/
public <U1, U2, U3> Cffu<Tuple3<U1, U2, U3>> thenTupleMApplyFastFailAsync(
Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3) {
return reset0(CompletableFutureUtils.thenTupleMApplyFastFailAsync(cf, fn1, fn2, fn3));
Function<? super T, ? extends U1> fn1,
Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) {
return thenTupleMApplyFastFailAsync(fac.defaultExecutor(), fn1, fn2, fn3);
}

/**
* Returns a new Cffu that, when this Cffu completes normally,
* is executed using the {@link #defaultExecutor()},
* Returns a new Cffu that, when this Cffu completes normally, is executed using the supplied Executor,
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
* <p>
* This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function, Function)}
* except for the fast-fail behavior.
*
* @return the new Cffu
*/
public <U1, U2, U3> Cffu<Tuple3<U1, U2, U3>> thenTupleMApplyFastFailAsync(
Executor executor, Function<? super T, ? extends U1> fn1,
Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) {
return reset0(CompletableFutureUtils.thenTupleMApplyFastFailAsync(cf, executor, fn1, fn2, fn3));
}

/**
* Returns a new Cffu that, when this Cffu completes normally, is executed using the {@link #defaultExecutor()},
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
Expand All @@ -266,12 +296,28 @@ public <U1, U2, U3> Cffu<Tuple3<U1, U2, U3>> thenTupleMApplyFastFailAsync(
public <U1, U2, U3, U4> Cffu<Tuple4<U1, U2, U3, U4>> thenTupleMApplyFastFailAsync(
Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) {
return reset0(CompletableFutureUtils.thenTupleMApplyFastFailAsync(cf, fn1, fn2, fn3, fn4));
return thenTupleMApplyFastFailAsync(fac.defaultExecutor(), fn1, fn2, fn3, fn4);
}

/**
* Returns a new Cffu that, when this Cffu completes normally, is executed using the supplied Executor,
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
* <p>
* This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function, Function, Function)}
* except for the fast-fail behavior.
*
* @return the new Cffu
*/
public <U1, U2, U3, U4> Cffu<Tuple4<U1, U2, U3, U4>> thenTupleMApplyFastFailAsync(
Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) {
return reset0(CompletableFutureUtils.thenTupleMApplyFastFailAsync(cf, executor, fn1, fn2, fn3, fn4));
}

/**
* Returns a new Cffu that, when this Cffu completes normally,
* is executed using the {@link #defaultExecutor()},
* Returns a new Cffu that, when this Cffu completes normally, is executed using the {@link #defaultExecutor()},
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
Expand All @@ -282,15 +328,32 @@ public <U1, U2, U3, U4> Cffu<Tuple4<U1, U2, U3, U4>> thenTupleMApplyFastFailAsyn
* @return the new Cffu
*/
public <U1, U2, U3, U4, U5> Cffu<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyFastFailAsync(
Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4,
Function<? super T, ? extends U5> fn5) {
return reset0(CompletableFutureUtils.thenTupleMApplyFastFailAsync(cf, fn1, fn2, fn3, fn4, fn5));
Function<? super T, ? extends U1> fn1,
Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3,
Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) {
return thenTupleMApplyFastFailAsync(fac.defaultExecutor(), fn1, fn2, fn3, fn4, fn5);
}

/**
* Returns a new Cffu that, when this Cffu completes normally, is executed using the supplied Executor,
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
* <p>
* This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function, Function, Function, Function)}
* except for the fast-fail behavior.
*
* @return the new Cffu
*/
public <U1, U2, U3, U4, U5> Cffu<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyFastFailAsync(
Executor executor, Function<? super T, ? extends U1> fn1,
Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3,
Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) {
return reset0(CompletableFutureUtils.thenTupleMApplyFastFailAsync(cf, executor, fn1, fn2, fn3, fn4, fn5));
}

/**
* Returns a new Cffu that, when this Cffu completes normally,
* is executed using the {@link #defaultExecutor()},
* Returns a new Cffu that, when this Cffu completes normally, is executed using the {@link #defaultExecutor()},
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
Expand All @@ -299,12 +362,24 @@ public <U1, U2, U3, U4, U5> Cffu<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyFast
*/
public <U1, U2> Cffu<Tuple2<U1, U2>> thenTupleMApplyAsync(
Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) {
return reset0(CompletableFutureUtils.thenTupleMApplyAsync(cf, fn1, fn2));
return thenTupleMApplyAsync(fac.defaultExecutor(), fn1, fn2);
}

/**
* Returns a new Cffu that, when this Cffu completes normally,
* is executed using the {@link #defaultExecutor()},
* Returns a new Cffu that, when this Cffu completes normally, is executed using the supplied Executor,
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
*
* @return the new Cffu
*/
public <U1, U2> Cffu<Tuple2<U1, U2>> thenTupleMApplyAsync(
Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) {
return reset0(CompletableFutureUtils.thenTupleMApplyAsync(cf, executor, fn1, fn2));
}

/**
* Returns a new Cffu that, when this Cffu completes normally, is executed using the {@link #defaultExecutor()},
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
Expand All @@ -314,12 +389,25 @@ public <U1, U2> Cffu<Tuple2<U1, U2>> thenTupleMApplyAsync(
public <U1, U2, U3> Cffu<Tuple3<U1, U2, U3>> thenTupleMApplyAsync(
Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3) {
return reset0(CompletableFutureUtils.thenTupleMApplyAsync(cf, fn1, fn2, fn3));
return thenTupleMApplyAsync(fac.defaultExecutor(), fn1, fn2, fn3);
}

/**
* Returns a new Cffu that, when this Cffu completes normally,
* is executed using the {@link #defaultExecutor()},
* Returns a new Cffu that, when this Cffu completes normally, is executed using the supplied Executor,
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
*
* @return the new Cffu
*/
public <U1, U2, U3> Cffu<Tuple3<U1, U2, U3>> thenTupleMApplyAsync(
Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3) {
return reset0(CompletableFutureUtils.thenTupleMApplyAsync(cf, executor, fn1, fn2, fn3));
}

/**
* Returns a new Cffu that, when this Cffu completes normally, is executed using the {@link #defaultExecutor()},
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
Expand All @@ -329,12 +417,25 @@ public <U1, U2, U3> Cffu<Tuple3<U1, U2, U3>> thenTupleMApplyAsync(
public <U1, U2, U3, U4> Cffu<Tuple4<U1, U2, U3, U4>> thenTupleMApplyAsync(
Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) {
return reset0(CompletableFutureUtils.thenTupleMApplyAsync(cf, fn1, fn2, fn3, fn4));
return thenTupleMApplyAsync(fac.defaultExecutor(), fn1, fn2, fn3, fn4);
}

/**
* Returns a new Cffu that, when this Cffu completes normally, is executed using the supplied Executor,
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
*
* @return the new Cffu
*/
public <U1, U2, U3, U4> Cffu<Tuple4<U1, U2, U3, U4>> thenTupleMApplyAsync(
Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) {
return reset0(CompletableFutureUtils.thenTupleMApplyAsync(cf, executor, fn1, fn2, fn3, fn4));
}

/**
* Returns a new Cffu that, when this Cffu completes normally,
* is executed using the {@link #defaultExecutor()},
* Returns a new Cffu that, when this Cffu completes normally, is executed using the {@link #defaultExecutor()},
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
Expand All @@ -345,7 +446,22 @@ public <U1, U2, U3, U4, U5> Cffu<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyAsyn
Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4,
Function<? super T, ? extends U5> fn5) {
return reset0(CompletableFutureUtils.thenTupleMApplyAsync(cf, fn1, fn2, fn3, fn4, fn5));
return thenTupleMApplyAsync(fac.defaultExecutor(), fn1, fn2, fn3, fn4, fn5);
}

/**
* Returns a new Cffu that, when this Cffu completes normally, is executed using the supplied Executor,
* with the values obtained by calling the given Functions
* (with this Cffu's result as the argument to the given functions)
* in the <strong>same order</strong> of the given Functions arguments.
*
* @return the new Cffu
*/
public <U1, U2, U3, U4, U5> Cffu<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyAsync(
Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2,
Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4,
Function<? super T, ? extends U5> fn5) {
return reset0(CompletableFutureUtils.thenTupleMApplyAsync(cf, executor, fn1, fn2, fn3, fn4, fn5));
}

// endregion
Expand Down

0 comments on commit b4d19ce

Please sign in to comment.