As part of the research effort in Reactive-Streams-Commons (Rsc) we have developed parallel version of the Publisher by vectorizing the Subscribers to a ParallelPublisher:
public abstract class ParallelPublisher<T> {
public abstract int parallelism();
public abstract boolean ordered();
public abstract void subscribe(Subscriber<? super T>[] subscribers);
// ... operators
}
whose copy is now part of Reactor-Core.
(RxJava 1.x has a companion library, RxJavaParallel, which doesn't seem to be working at all.)
The benefit of having a ParallelFlowable (and perhaps ParallelObservable) is that one can then fluently go parallel (and then back to sequential):
Flowable.range(1, 1000).parallel()
.runOn(Schedulers.computation())
.map(v -> someHeavyWork(v))
.sequential()
.subscribe(System.out::println);
The drawback is the increase in size, class and method count of the library, plus the additional way of getting confused about asynchrony, concurrency and parallelism regarding RxJava.
I suggest having at least the non-ordered version of the Rsc parallel classes for 2.0 and perhaps add the ordered variants to 2.1 or later.
Adding them takes a small amount of time because of simple copying and renaming elements in it.
As part of the research effort in Reactive-Streams-Commons (Rsc) we have developed parallel version of the
Publisherby vectorizing theSubscribers to aParallelPublisher:whose copy is now part of Reactor-Core.
(RxJava 1.x has a companion library, RxJavaParallel, which doesn't seem to be working at all.)
The benefit of having a
ParallelFlowable(and perhapsParallelObservable) is that one can then fluently go parallel (and then back to sequential):The drawback is the increase in size, class and method count of the library, plus the additional way of getting confused about asynchrony, concurrency and parallelism regarding RxJava.
I suggest having at least the non-ordered version of the Rsc parallel classes for 2.0 and perhaps add the ordered variants to 2.1 or later.
Adding them takes a small amount of time because of simple copying and renaming elements in it.