use of io.reactivex.rxjava3.internal.disposables.SequentialDisposable in project RxJava by ReactiveX.
the class SchedulerTest method disposeSelfPeriodic.
@Test
public void disposeSelfPeriodic() {
final int[] count = { 0 };
TestScheduler scheduler = new TestScheduler();
Worker worker = scheduler.createWorker();
try {
final SequentialDisposable sd = new SequentialDisposable();
Disposable d = worker.schedulePeriodically(new Runnable() {
@Override
public void run() {
count[0]++;
sd.dispose();
}
}, 100, 100, TimeUnit.MILLISECONDS);
sd.set(d);
assertEquals(0, count[0]);
assertFalse(d.isDisposed());
scheduler.advanceTimeBy(400, TimeUnit.MILLISECONDS);
assertEquals(1, count[0]);
assertTrue(d.isDisposed());
} finally {
worker.dispose();
}
}
Aggregations