Search in sources :

Example 1 with SingleScheduler

use of io.reactivex.rxjava3.internal.schedulers.SingleScheduler in project RxJava by ReactiveX.

the class CallableAsyncPerf method setup.

@Setup
public void setup() {
    Scheduler s = Schedulers.single();
    Scheduler s2 = new SingleScheduler();
    Callable<Integer> c = new Callable<Integer>() {

        @Override
        public Integer call() {
            return 1;
        }
    };
    subscribeOnFlowable = Flowable.fromCallable(c).subscribeOn(s);
    observeOnFlowable = Flowable.fromCallable(c).observeOn(s);
    pipelineFlowable = Flowable.fromCallable(c).subscribeOn(s).observeOn(s2);
    // ----
    subscribeOnObservable = Observable.fromCallable(c).subscribeOn(s);
    observeOnObservable = Observable.fromCallable(c).observeOn(s);
    pipelineObservable = Observable.fromCallable(c).subscribeOn(s).observeOn(s2);
    // ----
    observeOnSingle = Single.fromCallable(c).observeOn(s);
    subscribeOnSingle = Single.fromCallable(c).subscribeOn(s);
    pipelineSingle = Single.fromCallable(c).subscribeOn(s).observeOn(s2);
    // ----
    observeOnCompletable = Completable.fromCallable(c).observeOn(s);
    subscribeOnCompletable = Completable.fromCallable(c).subscribeOn(s);
    pipelineCompletable = Completable.fromCallable(c).subscribeOn(s).observeOn(s2);
    // ----
    observeOnMaybe = Maybe.fromCallable(c).observeOn(s);
    subscribeOnMaybe = Maybe.fromCallable(c).subscribeOn(s);
    pipelineMaybe = Maybe.fromCallable(c).subscribeOn(s).observeOn(s2);
}
Also used : SingleScheduler(io.reactivex.rxjava3.internal.schedulers.SingleScheduler) SingleScheduler(io.reactivex.rxjava3.internal.schedulers.SingleScheduler)

Example 2 with SingleScheduler

use of io.reactivex.rxjava3.internal.schedulers.SingleScheduler in project RxJava by ReactiveX.

the class JustAsyncPerf method setup.

@Setup
public void setup() {
    Scheduler s = Schedulers.single();
    Scheduler s2 = new SingleScheduler();
    subscribeOnFlowable = Flowable.just(1).subscribeOn(s);
    observeOnFlowable = Flowable.just(1).observeOn(s);
    pipelineFlowable = Flowable.just(1).subscribeOn(s).observeOn(s2);
    // ----
    subscribeOnObservable = Observable.just(1).subscribeOn(s);
    observeOnObservable = Observable.just(1).observeOn(s);
    pipelineObservable = Observable.just(1).subscribeOn(s).observeOn(s2);
    // ----
    observeOnSingle = Single.just(1).observeOn(s);
    subscribeOnSingle = Single.just(1).subscribeOn(s);
    pipelineSingle = Single.just(1).subscribeOn(s).observeOn(s2);
    // ----
    observeOnCompletable = Completable.complete().observeOn(s);
    subscribeOnCompletable = Completable.complete().subscribeOn(s);
    pipelineCompletable = Completable.complete().subscribeOn(s).observeOn(s2);
    // ----
    observeOnMaybe = Maybe.just(1).observeOn(s);
    subscribeOnMaybe = Maybe.just(1).subscribeOn(s);
    pipelineMaybe = Maybe.just(1).subscribeOn(s).observeOn(s2);
}
Also used : SingleScheduler(io.reactivex.rxjava3.internal.schedulers.SingleScheduler) SingleScheduler(io.reactivex.rxjava3.internal.schedulers.SingleScheduler)

Example 3 with SingleScheduler

use of io.reactivex.rxjava3.internal.schedulers.SingleScheduler in project RxJava by ReactiveX.

the class RangePerf method setup.

@Setup
public void setup() {
    range = Flowable.range(1, times);
    rangeAsync = range.observeOn(Schedulers.single());
    rangeAsyncPipeline = range.subscribeOn(new SingleScheduler()).observeOn(Schedulers.single());
}
Also used : SingleScheduler(io.reactivex.rxjava3.internal.schedulers.SingleScheduler)

Example 4 with SingleScheduler

use of io.reactivex.rxjava3.internal.schedulers.SingleScheduler in project RxJava by ReactiveX.

the class SingleSchedulerTest method shutdownRejects.

@Test
@SuppressUndeliverable
public void shutdownRejects() {
    final int[] calls = { 0 };
    Runnable r = new Runnable() {

        @Override
        public void run() {
            calls[0]++;
        }
    };
    Scheduler s = new SingleScheduler();
    s.shutdown();
    assertEquals(Disposable.disposed(), s.scheduleDirect(r));
    assertEquals(Disposable.disposed(), s.scheduleDirect(r, 1, TimeUnit.SECONDS));
    assertEquals(Disposable.disposed(), s.schedulePeriodicallyDirect(r, 1, 1, TimeUnit.SECONDS));
    Worker w = s.createWorker();
    ((ScheduledWorker) w).executor.shutdownNow();
    assertEquals(Disposable.disposed(), w.schedule(r));
    assertEquals(Disposable.disposed(), w.schedule(r, 1, TimeUnit.SECONDS));
    assertEquals(Disposable.disposed(), w.schedulePeriodically(r, 1, 1, TimeUnit.SECONDS));
    assertEquals(0, calls[0]);
    w.dispose();
    assertTrue(w.isDisposed());
}
Also used : Scheduler(io.reactivex.rxjava3.core.Scheduler) ScheduledWorker(io.reactivex.rxjava3.internal.schedulers.SingleScheduler.ScheduledWorker) Worker(io.reactivex.rxjava3.core.Scheduler.Worker) Test(org.junit.Test)

Example 5 with SingleScheduler

use of io.reactivex.rxjava3.internal.schedulers.SingleScheduler in project RxJava by ReactiveX.

the class SingleSchedulerTest method startRace.

@Test
public void startRace() {
    final Scheduler s = new SingleScheduler();
    for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
        s.shutdown();
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                s.start();
            }
        };
        TestHelper.race(r1, r1);
    }
}
Also used : Scheduler(io.reactivex.rxjava3.core.Scheduler) Test(org.junit.Test)

Aggregations

SingleScheduler (io.reactivex.rxjava3.internal.schedulers.SingleScheduler)3 Scheduler (io.reactivex.rxjava3.core.Scheduler)2 Test (org.junit.Test)2 Worker (io.reactivex.rxjava3.core.Scheduler.Worker)1 ScheduledWorker (io.reactivex.rxjava3.internal.schedulers.SingleScheduler.ScheduledWorker)1