use of io.reactivex.rxjava3.operators.QueueSubscription in project RxJava by ReactiveX.
the class FlowableObserveOnTest method outputFusedCancelReentrant.
@Test
public void outputFusedCancelReentrant() throws Exception {
final UnicastProcessor<Integer> up = UnicastProcessor.create();
final CountDownLatch cdl = new CountDownLatch(1);
up.observeOn(Schedulers.single()).subscribe(new FlowableSubscriber<Integer>() {
Subscription upstream;
int count;
@Override
public void onSubscribe(Subscription s) {
this.upstream = s;
((QueueSubscription<?>) s).requestFusion(QueueFuseable.ANY);
}
@Override
public void onNext(Integer value) {
if (++count == 1) {
up.onNext(2);
upstream.cancel();
cdl.countDown();
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
up.onNext(1);
cdl.await();
}
Aggregations