There was an error while loading. Please reload this page.
When SimpleReact is using a ForkJoinPool as a TaskExecutor, that can be used to replace the Common ForkJoinPool for the JDK ParallelStreams api.
Use collectResults().block().submit(result -> result.parallelStream()) to reuse the SimpleReact ForkJoinPool for ParallelStreams.
e.g.
Set<String> threadGroup = Collections.synchronizedSet(new TreeSet()); Integer result = new SimpleReact() .<Integer> react(() -> 1, () -> 2, () -> 3) .then((it) -> { threadGroup.add(Thread.currentThread().getThreadGroup().getName()); return it * 200;}) .collectResults().block().<Integer>submit( it -> it.parallelStream() .filter(f -> f > 300) .map(m ->{ threadGroup.add(Thread.currentThread().getThreadGroup().getName());return m - 5; }) .reduce(0, (acc, next) -> acc + next)); assertThat(result, is(990)); assertThat(threadGroup.size(), is(1));