You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuweni.apache.org by to...@apache.org on 2020/02/28 02:18:12 UTC

[incubator-tuweni] branch master updated: Expose the underlying Future in AsyncCompletion

This is an automated email from the ASF dual-hosted git repository.

toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git


The following commit(s) were added to refs/heads/master by this push:
     new 64d2730  Expose the underlying Future in AsyncCompletion
64d2730 is described below

commit 64d273087c000b95f24083702b346e4b0d8fdddf
Author: Antoine Toulme <an...@lunar-ocean.com>
AuthorDate: Thu Feb 27 18:17:52 2020 -0800

    Expose the underlying Future in AsyncCompletion
---
 .../main/java/org/apache/tuweni/concurrent/AsyncCompletion.java  | 8 ++++++++
 .../org/apache/tuweni/concurrent/CompletableAsyncCompletion.java | 9 +++++++++
 .../tuweni/concurrent/DefaultCompletableAsyncCompletion.java     | 5 +++++
 3 files changed, 22 insertions(+)

diff --git a/concurrent/src/main/java/org/apache/tuweni/concurrent/AsyncCompletion.java b/concurrent/src/main/java/org/apache/tuweni/concurrent/AsyncCompletion.java
index c495ce6..7a70427 100644
--- a/concurrent/src/main/java/org/apache/tuweni/concurrent/AsyncCompletion.java
+++ b/concurrent/src/main/java/org/apache/tuweni/concurrent/AsyncCompletion.java
@@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CompletionException;
 import java.util.concurrent.Executor;
 import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.function.Consumer;
@@ -475,4 +476,11 @@ public interface AsyncCompletion {
    * @return A new result.
    */
   AsyncCompletion accept(Consumer<? super Throwable> consumer);
+
+  /**
+   * Returns the underlying future associated with this instance.
+   *
+   * Note taking action directly on this future will impact this object.
+   */
+  Future<Void> toFuture();
 }
diff --git a/concurrent/src/main/java/org/apache/tuweni/concurrent/CompletableAsyncCompletion.java b/concurrent/src/main/java/org/apache/tuweni/concurrent/CompletableAsyncCompletion.java
index 5b0cb90..26e3d9c 100644
--- a/concurrent/src/main/java/org/apache/tuweni/concurrent/CompletableAsyncCompletion.java
+++ b/concurrent/src/main/java/org/apache/tuweni/concurrent/CompletableAsyncCompletion.java
@@ -12,6 +12,8 @@
  */
 package org.apache.tuweni.concurrent;
 
+import java.util.concurrent.CompletableFuture;
+
 /**
  * An {@link AsyncCompletion} that can later be completed successfully or with a provided exception.
  */
@@ -33,4 +35,11 @@ public interface CompletableAsyncCompletion extends AsyncCompletion {
    *         {@code false}.
    */
   boolean completeExceptionally(Throwable ex);
+
+  /**
+   * Returns the underlying completable future associated with this instance.
+   *
+   * Note taking action directly on this future will impact this object.
+   */
+  CompletableFuture<Void> toFuture();
 }
diff --git a/concurrent/src/main/java/org/apache/tuweni/concurrent/DefaultCompletableAsyncCompletion.java b/concurrent/src/main/java/org/apache/tuweni/concurrent/DefaultCompletableAsyncCompletion.java
index 8d17b8e..bff54b3 100644
--- a/concurrent/src/main/java/org/apache/tuweni/concurrent/DefaultCompletableAsyncCompletion.java
+++ b/concurrent/src/main/java/org/apache/tuweni/concurrent/DefaultCompletableAsyncCompletion.java
@@ -371,4 +371,9 @@ final class DefaultCompletableAsyncCompletion implements CompletableAsyncComplet
       return null;
     }));
   }
+
+  @Override
+  public CompletableFuture<Void> toFuture() {
+    return future;
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org