hu.akarnokd.rxjava2.parallel

## Class ParallelFlowable<T>

- java.lang.Object
- - hu.akarnokd.rxjava2.parallel.ParallelFlowable<T>

Type Parameters:
  `T` - the value type

    public abstract class ParallelFlowable<T>
    extends java.lang.Object

Abstract base class for Parallel publishers that take an array of Subscribers.

Use `from()` to start processing a regular Publisher in 'rails'. Use `runOn()` to introduce where each 'rail' shoud run on thread-vise. Use `sequential()` to merge the sources back into a single Flowable.

### Constructor Summary

Constructors
Constructor and Description
`ParallelFlowable()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`<C> ParallelFlowable<C>` `collect(java.util.concurrent.Callable<C> collectionSupplier, io.reactivex.functions.BiConsumer<C,T> collector)` Collect the elements in each rail into a collection supplied via a collectionSupplier and collected into with a collector action, emitting the collection at the end.
`<U> ParallelFlowable<U>` `compose(io.reactivex.functions.Function<? super ParallelFlowable<T>,ParallelFlowable<U>> composer)` Allows composing operators, in assembly time, on top of this ParallelFlowable and returns another ParallelFlowable with composed features.
`<R> ParallelFlowable<R>` `concatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)` Generates and concatenates Publishers on each 'rail', signalling errors immediately and generating 2 publishers upfront.
`<R> ParallelFlowable<R>` `concatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper, io.reactivex.internal.util.ErrorMode errorMode)` Generates and concatenates Publishers on each 'rail', optionally delaying errors and generating 2 publishers upfront.
`<R> ParallelFlowable<R>` `concatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper, int prefetch)` Generates and concatenates Publishers on each 'rail', signalling errors immediately and using the given prefetch amount for generating Publishers upfront.
`<R> ParallelFlowable<R>` `concatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper, int prefetch, io.reactivex.internal.util.ErrorMode errorMode)` Generates and concatenates Publishers on each 'rail', optionally delaying errors and using the given prefetch amount for generating Publishers upfront.
`ParallelFlowable<T>` `doAfterNext(io.reactivex.functions.Consumer<? super T> onAfterNext)` Call the specified consumer with the current element passing through any 'rail' after it has been delivered to downstream within the rail.
`ParallelFlowable<T>` `doAfterTerminated(io.reactivex.functions.Action onAfterTerminate)` Run the specified Action when a 'rail' completes or signals an error.
`ParallelFlowable<T>` `doOnCancel(io.reactivex.functions.Action onCancel)` Run the specified Action when a 'rail' receives a cancellation.
`ParallelFlowable<T>` `doOnComplete(io.reactivex.functions.Action onComplete)` Run the specified Action when a 'rail' completes.
`ParallelFlowable<T>` `doOnError(io.reactivex.functions.Consumer<java.lang.Throwable> onError)` Call the specified consumer with the exception passing through any 'rail'.
`ParallelFlowable<T>` `doOnNext(io.reactivex.functions.Consumer<? super T> onNext)` Call the specified consumer with the current element passing through any 'rail'.
`ParallelFlowable<T>` `doOnRequest(io.reactivex.functions.LongConsumer onRequest)` Call the specified consumer with the request amount if any rail receives a request.
`ParallelFlowable<T>` `doOnSubscribe(io.reactivex.functions.Consumer<? super org.reactivestreams.Subscription> onSubscribe)` Call the specified callback when a 'rail' receives a Subscription from its upstream.
`ParallelFlowable<T>` `filter(io.reactivex.functions.Predicate<? super T> predicate)` Filters the source values on each 'rail'.
`<R> ParallelFlowable<R>` `flatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)` Generates and flattens Publishers on each 'rail'.
`<R> ParallelFlowable<R>` `flatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper, boolean delayError)` Generates and flattens Publishers on each 'rail', optionally delaying errors.
`<R> ParallelFlowable<R>` `flatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper, boolean delayError, int maxConcurrency)` Generates and flattens Publishers on each 'rail', optionally delaying errors and having a total number of simultaneous subscriptions to the inner Publishers.

`<R> ParallelFlowable<R>`

`flatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper, boolean delayError, int maxConcurrency, int prefetch)`
Generates and flattens Publishers on each 'rail', optionally delaying errors, having a total number of simultaneous subscriptions to the inner Publishers and using the given prefetch amount for the inner Publishers.

`static <T> ParallelFlowable<T>` `from(org.reactivestreams.Publisher<? extends T> source)` Take a Publisher and prepare to consume it on multiple 'rails' (number of CPUs) in a round-robin fashion.
`static <T> ParallelFlowable<T>` `from(org.reactivestreams.Publisher<? extends T> source, int parallelism)` Take a Publisher and prepare to consume it on parallallism number of 'rails' in a round-robin fashion.
`static <T> ParallelFlowable<T>` `from(org.reactivestreams.Publisher<? extends T> source, int parallelism, int prefetch)` Take a Publisher and prepare to consume it on parallallism number of 'rails' , possibly ordered and round-robin fashion and use custom prefetch amount and queue for dealing with the source Publisher's values.
`static <T> ParallelFlowable<T>` `fromArray(org.reactivestreams.Publisher<T>... publishers)` Wraps multiple Publishers into a ParallelFlowable which runs them in parallel and unordered.
`<R> ParallelFlowable<R>` `map(io.reactivex.functions.Function<? super T,? extends R> mapper)` Maps the source values on each 'rail' to another value.
`abstract int` `parallelism()` Returns the number of expected parallel Subscribers.
`io.reactivex.Flowable<T>` `reduce(io.reactivex.functions.BiFunction<T,T,T> reducer)` Reduces all values within a 'rail' and across 'rails' with a reducer function into a single sequential value.
`<R> ParallelFlowable<R>` `reduce(java.util.concurrent.Callable<R> initialSupplier, io.reactivex.functions.BiFunction<R,T,R> reducer)` Reduces all values within a 'rail' to a single value (with a possibly different type) via a reducer function that is initialized on each rail from an initialSupplier value.
`ParallelFlowable<T>` `runOn(io.reactivex.Scheduler scheduler)` Specifies where each 'rail' will observe its incoming values with no work-stealing and default prefetch amount.
`ParallelFlowable<T>` `runOn(io.reactivex.Scheduler scheduler, int prefetch)` Specifies where each 'rail' will observe its incoming values with possibly work-stealing and a given prefetch amount.
`io.reactivex.Flowable<T>` `sequential()` Merges the values from each 'rail' in a round-robin or same-order fashion and exposes it as a regular Publisher sequence, running with a default prefetch value for the rails.
`io.reactivex.Flowable<T>` `sequential(int prefetch)` Merges the values from each 'rail' in a round-robin or same-order fashion and exposes it as a regular Publisher sequence, running with a give prefetch value for the rails.
`io.reactivex.Flowable<T>` `sorted(java.util.Comparator<? super T> comparator)` Sorts the 'rails' of this ParallelFlowable and returns a Publisher that sequentially picks the smallest next value from the rails.
`io.reactivex.Flowable<T>` `sorted(java.util.Comparator<? super T> comparator, int capacityHint)` Sorts the 'rails' of this ParallelFlowable and returns a Publisher that sequentially picks the smallest next value from the rails.
`abstract void` `subscribe(org.reactivestreams.Subscriber<? super T>[] subscribers)` Subscribes an array of Subscribers to this ParallelFlowable and triggers the execution chain for all 'rails'.
`<U> U` `to(io.reactivex.functions.Function<? super ParallelFlowable<T>,U> converter)` Perform a fluent transformation to a value via a converter function which receives this ParallelFlowable.
`io.reactivex.Flowable<java.util.List<T>>` `toSortedList(java.util.Comparator<? super T> comparator)` Sorts the 'rails' according to the comparator and returns a full sorted list as a Publisher.
`io.reactivex.Flowable<java.util.List<T>>` `toSortedList(java.util.Comparator<? super T> comparator, int capacityHint)` Sorts the 'rails' according to the comparator and returns a full sorted list as a Publisher.
`protected boolean` `validate(org.reactivestreams.Subscriber<?>[] subscribers)` Validates the number of subscribers and returns true if their number matches the parallelism level of this ParallelFlowable.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ParallelFlowable

    public ParallelFlowable()

### Method Detail

#### subscribe

    public abstract void subscribe(org.reactivestreams.Subscriber<? super T>[] subscribers)

Subscribes an array of Subscribers to this ParallelFlowable and triggers the execution chain for all 'rails'.

Parameters:
  `subscribers` - the subscribers array to run in parallel, the number of items must be equal to the parallelism level of this ParallelFlowable

#### parallelism

    public abstract int parallelism()

Returns the number of expected parallel Subscribers.

Returns:
  the number of expected parallel Subscribers

#### validate

    protected final boolean validate(org.reactivestreams.Subscriber<?>[] subscribers)

Validates the number of subscribers and returns true if their number matches the parallelism level of this ParallelFlowable.

Parameters:
  `subscribers` - the array of Subscribers
Returns:
  true if the number of subscribers equals to the parallelism level

#### from

    public static <T> ParallelFlowable<T> from(org.reactivestreams.Publisher<? extends T> source)

Take a Publisher and prepare to consume it on multiple 'rails' (number of CPUs) in a round-robin fashion.

Type Parameters:
  `T` - the value type
Parameters:
  `source` - the source Publisher
Returns:
  the ParallelFlowable instance

#### from

    public static <T> ParallelFlowable<T> from(org.reactivestreams.Publisher<? extends T> source,
                                               int parallelism)

Take a Publisher and prepare to consume it on parallallism number of 'rails' in a round-robin fashion.

Type Parameters:
  `T` - the value type
Parameters:
  `source` - the source Publisher
  `parallelism` - the number of parallel rails
Returns:
  the new ParallelFlowable instance

#### from

    public static <T> ParallelFlowable<T> from(org.reactivestreams.Publisher<? extends T> source,
                                               int parallelism,
                                               int prefetch)

Take a Publisher and prepare to consume it on parallallism number of 'rails' , possibly ordered and round-robin fashion and use custom prefetch amount and queue for dealing with the source Publisher's values.

Type Parameters:
  `T` - the value type
Parameters:
  `source` - the source Publisher
  `parallelism` - the number of parallel rails
  `prefetch` - the number of values to prefetch from the source the source until there is a rail ready to process it.
Returns:
  the new ParallelFlowable instance

#### map

    public final <R> ParallelFlowable<R> map(io.reactivex.functions.Function<? super T,? extends R> mapper)

Maps the source values on each 'rail' to another value.

Note that the same mapper function may be called from multiple threads concurrently.

Type Parameters:
  `R` - the output value type
Parameters:
  `mapper` - the mapper function turning Ts into Us.
Returns:
  the new ParallelFlowable instance

#### filter

    public final ParallelFlowable<T> filter(io.reactivex.functions.Predicate<? super T> predicate)

Filters the source values on each 'rail'.

Note that the same predicate may be called from multiple threads concurrently.

Parameters:
  `predicate` - the function returning true to keep a value or false to drop a value
Returns:
  the new ParallelFlowable instance

#### runOn

    public final ParallelFlowable<T> runOn(io.reactivex.Scheduler scheduler)

Specifies where each 'rail' will observe its incoming values with no work-stealing and default prefetch amount.

This operator uses the default prefetch size returned by `Flowable.bufferSize()`.

The operator will call `Scheduler.createWorker()` as many times as this ParallelFlowable's parallelism level is.

No assumptions are made about the Scheduler's parallelism level, if the Scheduler's parallelism level is lwer than the ParallelFlowable's, some rails may end up on the same thread/worker.

This operator doesn't require the Scheduler to be trampolining as it does its own built-in trampolining logic.

Parameters:
  `scheduler` - the scheduler to use
Returns:
  the new ParallelFlowable instance

#### runOn

    public final ParallelFlowable<T> runOn(io.reactivex.Scheduler scheduler,
                                           int prefetch)

Specifies where each 'rail' will observe its incoming values with possibly work-stealing and a given prefetch amount.

This operator uses the default prefetch size returned by `Flowable.bufferSize()`.

The operator will call `Scheduler.createWorker()` as many times as this ParallelFlowable's parallelism level is.

No assumptions are made about the Scheduler's parallelism level, if the Scheduler's parallelism level is lwer than the ParallelFlowable's, some rails may end up on the same thread/worker.

This operator doesn't require the Scheduler to be trampolining as it does its own built-in trampolining logic.

Parameters:
  `scheduler` - the scheduler to use that rail's worker has run out of work.
  `prefetch` - the number of values to request on each 'rail' from the source
Returns:
  the new ParallelFlowable instance

#### reduce

    public final io.reactivex.Flowable<T> reduce(io.reactivex.functions.BiFunction<T,T,T> reducer)

Reduces all values within a 'rail' and across 'rails' with a reducer function into a single sequential value.

Note that the same reducer function may be called from multiple threads concurrently.

Parameters:
  `reducer` - the function to reduce two values into one.
Returns:
  the new Px instance emitting the reduced value or empty if the ParallelFlowable was empty

#### reduce

    public final <R> ParallelFlowable<R> reduce(java.util.concurrent.Callable<R> initialSupplier,
                                                io.reactivex.functions.BiFunction<R,T,R> reducer)

Reduces all values within a 'rail' to a single value (with a possibly different type) via a reducer function that is initialized on each rail from an initialSupplier value.

Note that the same mapper function may be called from multiple threads concurrently.

Type Parameters:
  `R` - the reduced output type
Parameters:
  `initialSupplier` - the supplier for the initial value
  `reducer` - the function to reduce a previous output of reduce (or the initial value supplied) with a current source value.
Returns:
  the new ParallelFlowable instance

#### sequential

    public final io.reactivex.Flowable<T> sequential()

Merges the values from each 'rail' in a round-robin or same-order fashion and exposes it as a regular Publisher sequence, running with a default prefetch value for the rails.

This operator uses the default prefetch size returned by `Flowable.bufferSize()`.

Returns:
  the new Px instance
See Also:
  `sequential(int)`

#### sequential

    public final io.reactivex.Flowable<T> sequential(int prefetch)

Merges the values from each 'rail' in a round-robin or same-order fashion and exposes it as a regular Publisher sequence, running with a give prefetch value for the rails.

Parameters:
  `prefetch` - the prefetch amount to use for each rail
Returns:
  the new Px instance
See Also:
  `sequential()`

#### sorted

    public final io.reactivex.Flowable<T> sorted(java.util.Comparator<? super T> comparator)

Sorts the 'rails' of this ParallelFlowable and returns a Publisher that sequentially picks the smallest next value from the rails.

This operator requires a finite source ParallelFlowable.

Parameters:
  `comparator` - the comparator to use
Returns:
  the new Px instance

#### sorted

    public final io.reactivex.Flowable<T> sorted(java.util.Comparator<? super T> comparator,
                                                 int capacityHint)

Sorts the 'rails' of this ParallelFlowable and returns a Publisher that sequentially picks the smallest next value from the rails.

This operator requires a finite source ParallelFlowable.

Parameters:
  `comparator` - the comparator to use
  `capacityHint` - the expected number of total elements
Returns:
  the new Px instance

#### toSortedList

    public final io.reactivex.Flowable<java.util.List<T>> toSortedList(java.util.Comparator<? super T> comparator)

Sorts the 'rails' according to the comparator and returns a full sorted list as a Publisher.

This operator requires a finite source ParallelFlowable.

Parameters:
  `comparator` - the comparator to compare elements
Returns:
  the new Px instannce

#### toSortedList

    public final io.reactivex.Flowable<java.util.List<T>> toSortedList(java.util.Comparator<? super T> comparator,
                                                                       int capacityHint)

Sorts the 'rails' according to the comparator and returns a full sorted list as a Publisher.

This operator requires a finite source ParallelFlowable.

Parameters:
  `comparator` - the comparator to compare elements
  `capacityHint` - the expected number of total elements
Returns:
  the new Px instannce

#### doOnNext

    public final ParallelFlowable<T> doOnNext(io.reactivex.functions.Consumer<? super T> onNext)

Call the specified consumer with the current element passing through any 'rail'.

Parameters:
  `onNext` - the callback
Returns:
  the new ParallelFlowable instance

#### doAfterNext

    public final ParallelFlowable<T> doAfterNext(io.reactivex.functions.Consumer<? super T> onAfterNext)

Call the specified consumer with the current element passing through any 'rail' after it has been delivered to downstream within the rail.

Parameters:
  `onAfterNext` - the callback
Returns:
  the new ParallelFlowable instance

#### doOnError

    public final ParallelFlowable<T> doOnError(io.reactivex.functions.Consumer<java.lang.Throwable> onError)

Call the specified consumer with the exception passing through any 'rail'.

Parameters:
  `onError` - the callback
Returns:
  the new ParallelFlowable instance

#### doOnComplete

    public final ParallelFlowable<T> doOnComplete(io.reactivex.functions.Action onComplete)

Run the specified Action when a 'rail' completes.

Parameters:
  `onComplete` - the callback
Returns:
  the new ParallelFlowable instance

#### doAfterTerminated

    public final ParallelFlowable<T> doAfterTerminated(io.reactivex.functions.Action onAfterTerminate)

Run the specified Action when a 'rail' completes or signals an error.

Parameters:
  `onAfterTerminate` - the callback
Returns:
  the new ParallelFlowable instance

#### doOnSubscribe

    public final ParallelFlowable<T> doOnSubscribe(io.reactivex.functions.Consumer<? super org.reactivestreams.Subscription> onSubscribe)

Call the specified callback when a 'rail' receives a Subscription from its upstream.

Parameters:
  `onSubscribe` - the callback
Returns:
  the new ParallelFlowable instance

#### doOnRequest

    public final ParallelFlowable<T> doOnRequest(io.reactivex.functions.LongConsumer onRequest)

Call the specified consumer with the request amount if any rail receives a request.

Parameters:
  `onRequest` - the callback
Returns:
  the new ParallelFlowable instance

#### doOnCancel

    public final ParallelFlowable<T> doOnCancel(io.reactivex.functions.Action onCancel)

Run the specified Action when a 'rail' receives a cancellation.

Parameters:
  `onCancel` - the callback
Returns:
  the new ParallelFlowable instance

#### collect

    public final <C> ParallelFlowable<C> collect(java.util.concurrent.Callable<C> collectionSupplier,
                                                 io.reactivex.functions.BiConsumer<C,T> collector)

Collect the elements in each rail into a collection supplied via a collectionSupplier and collected into with a collector action, emitting the collection at the end.

Type Parameters:
  `C` - the collection type
Parameters:
  `collectionSupplier` - the supplier of the collection in each rail
  `collector` - the collector, taking the per-rali collection and the current item
Returns:
  the new ParallelFlowable instance

#### fromArray

    public static <T> ParallelFlowable<T> fromArray(org.reactivestreams.Publisher<T>... publishers)

Wraps multiple Publishers into a ParallelFlowable which runs them in parallel and unordered.

Type Parameters:
  `T` - the value type
Parameters:
  `publishers` - the array of publishers
Returns:
  the new ParallelFlowable instance

#### to

    public final <U> U to(io.reactivex.functions.Function<? super ParallelFlowable<T>,U> converter)

Perform a fluent transformation to a value via a converter function which receives this ParallelFlowable.

Type Parameters:
  `U` - the output value type
Parameters:
  `converter` - the converter function from ParallelFlowable to some type
Returns:
  the value returned by the converter function

#### compose

    public final <U> ParallelFlowable<U> compose(io.reactivex.functions.Function<? super ParallelFlowable<T>,ParallelFlowable<U>> composer)

Allows composing operators, in assembly time, on top of this ParallelFlowable and returns another ParallelFlowable with composed features.

Type Parameters:
  `U` - the output value type
Parameters:
  `composer` - the composer function from ParallelFlowable (this) to another ParallelFlowable
Returns:
  the ParallelFlowable returned by the function

#### flatMap

    public final <R> ParallelFlowable<R> flatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)

Generates and flattens Publishers on each 'rail'.

Errors are not delayed and uses unbounded concurrency along with default inner prefetch.

Type Parameters:
  `R` - the result type
Parameters:
  `mapper` - the function to map each rail's value into a Publisher
Returns:
  the new ParallelFlowable instance

#### flatMap

    public final <R> ParallelFlowable<R> flatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper,
                                                 boolean delayError)

Generates and flattens Publishers on each 'rail', optionally delaying errors.

It uses unbounded concurrency along with default inner prefetch.

Type Parameters:
  `R` - the result type
Parameters:
  `mapper` - the function to map each rail's value into a Publisher
  `delayError` - should the errors from the main and the inner sources delayed till everybody terminates?
Returns:
  the new ParallelFlowable instance

#### flatMap

    public final <R> ParallelFlowable<R> flatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper,
                                                 boolean delayError,
                                                 int maxConcurrency)

Generates and flattens Publishers on each 'rail', optionally delaying errors and having a total number of simultaneous subscriptions to the inner Publishers.

It uses a default inner prefetch.

Type Parameters:
  `R` - the result type
Parameters:
  `mapper` - the function to map each rail's value into a Publisher
  `delayError` - should the errors from the main and the inner sources delayed till everybody terminates?
  `maxConcurrency` - the maximum number of simultaneous subscriptions to the generated inner Publishers
Returns:
  the new ParallelFlowable instance

#### flatMap

    public final <R> ParallelFlowable<R> flatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper,
                                                 boolean delayError,
                                                 int maxConcurrency,
                                                 int prefetch)

Generates and flattens Publishers on each 'rail', optionally delaying errors, having a total number of simultaneous subscriptions to the inner Publishers and using the given prefetch amount for the inner Publishers.

Type Parameters:
  `R` - the result type
Parameters:
  `mapper` - the function to map each rail's value into a Publisher
  `delayError` - should the errors from the main and the inner sources delayed till everybody terminates?
  `maxConcurrency` - the maximum number of simultaneous subscriptions to the generated inner Publishers
  `prefetch` - the number of items to prefetch from each inner Publisher
Returns:
  the new ParallelFlowable instance

#### concatMap

    public final <R> ParallelFlowable<R> concatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)

Generates and concatenates Publishers on each 'rail', signalling errors immediately and generating 2 publishers upfront.

Type Parameters:
  `R` - the result type
Parameters:
  `mapper` - the function to map each rail's value into a Publisher source and the inner Publishers (immediate, boundary, end)
Returns:
  the new ParallelFlowable instance

#### concatMap

    public final <R> ParallelFlowable<R> concatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper,
                                                   int prefetch)

Generates and concatenates Publishers on each 'rail', signalling errors immediately and using the given prefetch amount for generating Publishers upfront.

Type Parameters:
  `R` - the result type
Parameters:
  `mapper` - the function to map each rail's value into a Publisher
  `prefetch` - the number of items to prefetch from each inner Publisher source and the inner Publishers (immediate, boundary, end)
Returns:
  the new ParallelFlowable instance

#### concatMap

    public final <R> ParallelFlowable<R> concatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper,
                                                   io.reactivex.internal.util.ErrorMode errorMode)

Generates and concatenates Publishers on each 'rail', optionally delaying errors and generating 2 publishers upfront.

Type Parameters:
  `R` - the result type
Parameters:
  `mapper` - the function to map each rail's value into a Publisher
  `errorMode` - the error handling, i.e., when to report errors from the main source and the inner Publishers (immediate, boundary, end)
Returns:
  the new ParallelFlowable instance

#### concatMap

    public final <R> ParallelFlowable<R> concatMap(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper,
                                                   int prefetch,
                                                   io.reactivex.internal.util.ErrorMode errorMode)

Generates and concatenates Publishers on each 'rail', optionally delaying errors and using the given prefetch amount for generating Publishers upfront.

Type Parameters:
  `R` - the result type
Parameters:
  `mapper` - the function to map each rail's value into a Publisher
  `prefetch` - the number of items to prefetch from each inner Publisher
  `errorMode` - the error handling, i.e., when to report errors from the main source and the inner Publishers (immediate, boundary, end)
Returns:
  the new ParallelFlowable instance