@@ -13045,6 +13045,44 @@ public final <E extends Subscriber<? super T>> E subscribeWith(E subscriber) {
13045
13045
/**
13046
13046
* Asynchronously subscribes Subscribers to this Publisher on the specified {@link Scheduler}.
13047
13047
* <p>
13048
+ * If there is a {@link #create(FlowableOnSubscribe, BackpressureStrategy)} type source up in the
13049
+ * chain, it is recommended to use {@code subscribeOn(scheduler, false)} instead
13050
+ * to avoid same-pool deadlock because requests may pile up behind a eager/blocking emitter.
13051
+ * <p>
13052
+ * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/subscribeOn.png" alt="">
13053
+ * <dl>
13054
+ * <dt><b>Backpressure:</b></dt>
13055
+ * <dd>The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s backpressure
13056
+ * behavior.</dd>
13057
+ * <dt><b>Scheduler:</b></dt>
13058
+ * <dd>You specify which {@link Scheduler} this operator will use</dd>
13059
+ * </dl>
13060
+ *
13061
+ * @param scheduler
13062
+ * the {@link Scheduler} to perform subscription actions on
13063
+ * @return the source Publisher modified so that its subscriptions happen on the
13064
+ * specified {@link Scheduler}
13065
+ * @see <a href="http://reactivex.io/documentation/operators/subscribeon.html">ReactiveX operators documentation: SubscribeOn</a>
13066
+ * @see <a href="http://www.grahamlea.com/2014/07/rxjava-threading-examples/">RxJava Threading Examples</a>
13067
+ * @see #observeOn
13068
+ * @see #subscribeOn(Scheduler, boolean)
13069
+ */
13070
+ @CheckReturnValue
13071
+ @BackpressureSupport(BackpressureKind.PASS_THROUGH)
13072
+ @SchedulerSupport(SchedulerSupport.CUSTOM)
13073
+ public final Flowable<T> subscribeOn(@NonNull Scheduler scheduler) {
13074
+ ObjectHelper.requireNonNull(scheduler, "scheduler is null");
13075
+ return subscribeOn(scheduler, !(this instanceof FlowableCreate));
13076
+ }
13077
+
13078
+ /**
13079
+ * Asynchronously subscribes Subscribers to this Publisher on the specified {@link Scheduler}
13080
+ * optionally reroutes requests from other threads to the same {@link Scheduler} thread.
13081
+ * <p>
13082
+ * If there is a {@link #create(FlowableOnSubscribe, BackpressureStrategy)} type source up in the
13083
+ * chain, it is recommended to have {@code requestOn} false to avoid same-pool deadlock
13084
+ * because requests may pile up behind a eager/blocking emitter.
13085
+ * <p>
13048
13086
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/subscribeOn.png" alt="">
13049
13087
* <dl>
13050
13088
* <dt><b>Backpressure:</b></dt>
@@ -13056,18 +13094,23 @@ public final <E extends Subscriber<? super T>> E subscribeWith(E subscriber) {
13056
13094
*
13057
13095
* @param scheduler
13058
13096
* the {@link Scheduler} to perform subscription actions on
13097
+ * @param requestOn if true, requests are rerouted to the given Scheduler as well (strong pipelining)
13098
+ * if false, requests coming from any thread are simply forwarded to
13099
+ * the upstream on the same thread (weak pipelining)
13059
13100
* @return the source Publisher modified so that its subscriptions happen on the
13060
13101
* specified {@link Scheduler}
13061
13102
* @see <a href="http://reactivex.io/documentation/operators/subscribeon.html">ReactiveX operators documentation: SubscribeOn</a>
13062
13103
* @see <a href="http://www.grahamlea.com/2014/07/rxjava-threading-examples/">RxJava Threading Examples</a>
13063
13104
* @see #observeOn
13105
+ * @since 2.1.1 - experimental
13064
13106
*/
13065
13107
@CheckReturnValue
13066
13108
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
13067
13109
@SchedulerSupport(SchedulerSupport.CUSTOM)
13068
- public final Flowable<T> subscribeOn(Scheduler scheduler) {
13110
+ @Experimental
13111
+ public final Flowable<T> subscribeOn(@NonNull Scheduler scheduler, boolean requestOn) {
13069
13112
ObjectHelper.requireNonNull(scheduler, "scheduler is null");
13070
- return RxJavaPlugins.onAssembly(new FlowableSubscribeOn<T>(this, scheduler, this instanceof FlowableCreate ));
13113
+ return RxJavaPlugins.onAssembly(new FlowableSubscribeOn<T>(this, scheduler, requestOn ));
13071
13114
}
13072
13115
13073
13116
/**
0 commit comments