Search in sources :

Example 6 with RxThreadFactory

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

the class SingleSchedulerTest method zeroPeriodRejectedExecution.

@Test
public void zeroPeriodRejectedExecution() throws Throwable {
    TestHelper.withErrorTracking(errors -> {
        Scheduler s = RxJavaPlugins.createSingleScheduler(new RxThreadFactory("Test"));
        s.shutdown();
        Runnable run = mock(Runnable.class);
        s.schedulePeriodicallyDirect(run, 1, 0, TimeUnit.MILLISECONDS);
        Thread.sleep(100);
        verify(run, never()).run();
        TestHelper.assertUndeliverable(errors, 0, RejectedExecutionException.class);
    });
}
Also used : Scheduler(io.reactivex.rxjava3.core.Scheduler) Test(org.junit.Test)

Example 7 with RxThreadFactory

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

the class ExecutorSchedulerTest method runnableDisposedAsyncTimed2.

@Test
public void runnableDisposedAsyncTimed2() throws Exception {
    ExecutorService executorScheduler = Executors.newScheduledThreadPool(1, new RxThreadFactory("TestCustomPoolTimed"));
    try {
        final Scheduler s = Schedulers.from(executorScheduler);
        Disposable d = s.scheduleDirect(Functions.EMPTY_RUNNABLE, 1, TimeUnit.MILLISECONDS);
        while (!d.isDisposed()) {
            Thread.sleep(1);
        }
    } finally {
        executorScheduler.shutdownNow();
    }
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable) Scheduler(io.reactivex.rxjava3.core.Scheduler) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)3 Scheduler (io.reactivex.rxjava3.core.Scheduler)3 CompositeDisposable (io.reactivex.rxjava3.disposables.CompositeDisposable)3 Disposable (io.reactivex.rxjava3.disposables.Disposable)3 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)3 EmptyDisposable (io.reactivex.rxjava3.internal.disposables.EmptyDisposable)2 RxThreadFactory (io.reactivex.rxjava3.internal.schedulers.RxThreadFactory)2