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);
}
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);
}
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());
}
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());
}
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);
}
}
Aggregations