use of io.reactivex.rxjava3.operators.QueueDisposable in project RxJava by ReactiveX.
the class ObservableObserveOnTest method outputFusedCancelReentrant.
@Test
public void outputFusedCancelReentrant() throws Exception {
final UnicastSubject<Integer> us = UnicastSubject.create();
final CountDownLatch cdl = new CountDownLatch(1);
us.observeOn(Schedulers.single()).subscribe(new Observer<Integer>() {
Disposable upstream;
int count;
@Override
public void onSubscribe(Disposable d) {
this.upstream = d;
((QueueDisposable<?>) d).requestFusion(QueueFuseable.ANY);
}
@Override
public void onNext(Integer value) {
if (++count == 1) {
us.onNext(2);
upstream.dispose();
cdl.countDown();
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
us.onNext(1);
cdl.await();
}
Aggregations