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

sewen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 772eb8ec99530fec7f32cfcfb24537013067a3db
Author: Stephan Ewen <se...@apache.org>
AuthorDate: Wed Mar 31 19:33:06 2021 +0200

    [refactor][runtime] Update FutureUtils to support delayed completing of a 
CompletableFuture
---
 .../org/apache/flink/runtime/concurrent/FutureUtils.java  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java
 
b/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java
index 4334eda..26384e2 100644
--- 
a/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java
+++ 
b/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java
@@ -595,6 +595,21 @@ public class FutureUtils {
     }
 
     // ------------------------------------------------------------------------
+    //  Delayed completion
+    // ------------------------------------------------------------------------
+
+    /**
+     * Asynchronously completes the future after a certain delay.
+     *
+     * @param future The future to complete.
+     * @param success The element to complete the future with.
+     * @param delay The delay after which the future should be completed.
+     */
+    public static <T> void completeDelayed(CompletableFuture<T> future, T 
success, Duration delay) {
+        Delayer.delay(() -> future.complete(success), delay.toMillis(), 
TimeUnit.MILLISECONDS);
+    }
+
+    // ------------------------------------------------------------------------
     //  Future actions
     // ------------------------------------------------------------------------
 

Reply via email to