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 31acaf03..2f30491c 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java @@ -157,14 +157,6 @@ public CompletionStage failedStage(Throwable ex) { // - supplyAsync* //////////////////////////////////////////////////////////////////////////////// - /** - * a completed Cffu with the value {@code null} - */ - @Contract(pure = true) - private Cffu dummy() { - return completedFuture(null); - } - /** * Returns a new Cffu that is asynchronously completed by a task running * in the {@link #defaultExecutor()} after it runs the given action. @@ -174,7 +166,7 @@ private Cffu dummy() { * @see CompletableFuture#runAsync(Runnable) */ public Cffu runAsync(Runnable action) { - return dummy().thenRunAsync(action); + return runAsync(action, defaultExecutor); } /** @@ -187,7 +179,7 @@ public Cffu runAsync(Runnable action) { * @see CompletableFuture#runAsync(Runnable, Executor) */ public Cffu runAsync(Runnable action, Executor executor) { - return dummy().thenRunAsync(action, executor); + return new0(CompletableFuture.runAsync(action, executor)); } /** @@ -203,7 +195,7 @@ public Cffu runAsync(Runnable action, Executor executor) { @CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `runAsync`") @SuppressWarnings("BoundedWildcard") public Cffu supplyAsync(Supplier supplier) { - return dummy().thenApplyAsync(unused -> supplier.get()); + return supplyAsync(supplier, defaultExecutor); } /** @@ -219,7 +211,7 @@ public Cffu supplyAsync(Supplier supplier) { @CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `runAsync`") @SuppressWarnings("BoundedWildcard") public Cffu supplyAsync(Supplier supplier, Executor executor) { - return dummy().thenApplyAsync(unused -> supplier.get(), executor); + return new0(CompletableFuture.supplyAsync(supplier, executor)); } ////////////////////////////////////////////////////////////////////////////////