Technoboy- commented on code in PR #15527:
URL: https://github.com/apache/pulsar/pull/15527#discussion_r873342728


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java:
##########
@@ -47,6 +50,18 @@ public static CompletableFuture<Void> 
waitForAll(Collection<? extends Completabl
         return CompletableFuture.allOf(futures.toArray(new 
CompletableFuture[0]));
     }
 
+    public static <T> CompletableFuture<List<T>> 
waitForAll(Stream<CompletableFuture<List<T>>> futures) {
+        return futures.reduce(CompletableFuture.completedFuture(new 
ArrayList<>()),
+                (pre, curr) -> pre.thenCompose(preV -> curr.thenApply(currV -> 
{
+                    preV.addAll(currV);
+                    return preV;
+                })));
+    }
+
+    public static <T> CompletableFuture<List<T>> 
waitForAll(List<CompletableFuture<List<T>>> futures) {
+        return waitForAll(futures.stream());

Review Comment:
   And here.



-- 
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]

Reply via email to