Skip to content

Commit

Permalink
clean up Fanout javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
fluentfuture committed Dec 23, 2024
1 parent 4c3b877 commit 21831c3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mug/src/main/java/com/google/mu/util/concurrent/Fanout.java
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,18 @@ public static void uninterruptibly(Runnable task1, Runnable task2, Runnable... m
* .toMap();
* }</pre>
*
* Compared to parallel streams, you can control the concurrency. Exceptions also retain the
* full stack trace from both the main thread and the virtual thread.
* Functionally, the {@link Parallelizer#inParallel} collector is very similar to the Java 25
* {@code mapConcurrent()} Gatherer:
*
* <pre>{@code
* List<UserId> userIds = ;
* List<User> users = userIds.stream()
* .gather(mapConcurrent(userService::fetchUser, 10))
* .toList();
* }</pre>
*
* But it provides extra flexibility because with {@code Fanout} you can customize the executor
* by using {@link StructuredConcurrencyExecutorPlugin}.
*/
public static Parallelizer withMaxConcurrency(int maxConcurrency) {
return new Parallelizer(Scope.executor, maxConcurrency);
Expand Down

0 comments on commit 21831c3

Please sign in to comment.