nosewings commented on code in PR #2752:
URL: https://github.com/apache/accumulo/pull/2752#discussion_r899233943
##########
core/src/main/java/org/apache/accumulo/core/util/CompletableFutureUtil.java:
##########
@@ -49,4 +51,28 @@ public static <T> CompletableFuture<T>
merge(List<CompletableFuture<T>> futures,
return futures.get(0);
}
+ /**
+ * Asynchronously, iterate some function until a given condition is met.
+ */
+ public static <T> CompletableFuture<T>
iterateWhileAsync(Function<T,CompletableFuture<T>> step,
+ Predicate<T> isDone, T init) {
+ // We'd like to use a lambda here, but lambdas don't have
+ // `this`, so we would have to use some clumsy indirection to
+ // achieve self-reference.
+ Function<T,CompletableFuture<T>> go = new Function<>() {
+ @Override
+ public CompletableFuture<T> apply(T x) {
+ if (isDone.test(x)) {
+ return CompletableFuture.completedFuture(x);
+ }
+ // Making the recursive call with thenComposeAsync prevents
+ // stack overflows (but risks deadlock if we run out of
+ // threads).
+ //
+ // TODO should this method take an ExecutorService argument?
Review Comment:
Not needed anymore, since all the async calls are removed.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]