You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Possibly create a way to join and map CompletableFutures.
publicstatic <T1, T2, T3> Tuple3<T1, T2, T3> joinAll(
CompletableFuture<T1> f1,
CompletableFuture<T2> f2,
CompletableFuture<T3> f3) {
// Do we even need this allOf since we join below anyway.CompletableFuture.allOf(f1, f2, f3).join();
returnTuple.tuple(f1.join(), f2.join(), f3.join());
}
Could be combined like so. return Futures.joinAll(emailFuture, tagFuture, rolesFuture).map(User::new);
Thank you very much for your suggestion. That is an interesting approach. Should we decide to provide utilities for the JDK's concurrency APIs (see also #283), this multi-join-into-tuple approach definitely makes sense.
@lukaseder any thoughts on this since we added the new CompletionStage? Ideally it would accept CompletionStages but they would need to be converted to CompletableFuture to call join() or CompletableFuture.allOf(
Thanks for pinging, @billoneil. I think this idea needs to ripe a bit, first. Improving this area seems to be scratching an itch that few people have, and at this stage, I'm very uncertain of what a good API would be. I currently don't want to rush adding this new API.
Possibly create a way to join and map CompletableFutures.
Could be combined like so.
return Futures.joinAll(emailFuture, tagFuture, rolesFuture).map(User::new);
Full example shown here https://gist.github.com/billoneil/f949def19560f379bec9aa640b19120c#file-gistfile1-java-L23
The text was updated successfully, but these errors were encountered: