cmccabe commented on code in PR #13153:
URL: https://github.com/apache/kafka/pull/13153#discussion_r1089313497


##########
clients/src/main/java/org/apache/kafka/common/utils/Time.java:
##########
@@ -86,4 +89,30 @@ default Timer timer(Duration timeout) {
         return timer(timeout.toMillis());
     }
 
+    /**
+     * Wait for a future to complete, or time out.
+     *
+     * @param future        The future to wait for.
+     * @param deadlineNs    The time in the future, in monotonic nanoseconds, 
to time out.
+     * @return              The result of the future.
+     * @param <T>           The type of the future.
+     */
+    default <T> T waitForFuture(
+        CompletableFuture<T> future,
+        long deadlineNs
+    ) throws TimeoutException, InterruptedException, ExecutionException  {
+        TimeoutException timeoutException = null;
+        while (true) {

Review Comment:
   It's a bit unclear. It's traditional for condition variables to allow 
spurious wakeups, and probably this is implemented with a condition variable. 
The JavaDoc for `get` just says that it will wait "at most the given time" 
which doesn't really clarify matters. In any case, the loop certainly does no 
harm.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to