Search in sources :

Example 1 with SubscribeOnSubscriber

use of io.reactivex.internal.operators.flowable.FlowableSubscribeOn.SubscribeOnSubscriber in project RxJava by ReactiveX.

the class FlowableSubscribeOnTest method deferredRequestRace.

@Test
public void deferredRequestRace() {
    for (int i = 0; i < 500; i++) {
        final TestSubscriber<Integer> ts = new TestSubscriber<Integer>(0L);
        Worker w = Schedulers.computation().createWorker();
        final SubscribeOnSubscriber<Integer> so = new SubscribeOnSubscriber<Integer>(ts, w, Flowable.<Integer>never(), true);
        ts.onSubscribe(so);
        final BooleanSubscription bs = new BooleanSubscription();
        try {
            Runnable r1 = new Runnable() {

                @Override
                public void run() {
                    so.onSubscribe(bs);
                }
            };
            Runnable r2 = new Runnable() {

                @Override
                public void run() {
                    so.request(1);
                }
            };
            TestHelper.race(r1, r2);
        } finally {
            w.dispose();
        }
    }
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) SubscribeOnSubscriber(io.reactivex.internal.operators.flowable.FlowableSubscribeOn.SubscribeOnSubscriber) Worker(io.reactivex.Scheduler.Worker)

Aggregations

Worker (io.reactivex.Scheduler.Worker)1 SubscribeOnSubscriber (io.reactivex.internal.operators.flowable.FlowableSubscribeOn.SubscribeOnSubscriber)1 BooleanSubscription (io.reactivex.internal.subscriptions.BooleanSubscription)1