Interface QueueSubscription<T>
- Type Parameters:
T- the value type transmitted through the queue
- All Superinterfaces:
Flow.Subscription, QueueFuseable<T>, SimpleQueue<T>
SimpleQueue and Flow.Subscription and allows negotiating
the fusion mode between subsequent operators of the Flowable base reactive type.
The negotiation happens in subscription time when the upstream
calls the onSubscribe with an instance of this interface. The
downstream has then the obligation to call QueueFuseable.requestFusion(int)
with the appropriate mode before calling request().
In synchronous fusion, all upstream values are either already available or is generated
when SimpleQueue.poll() is called synchronously. When the SimpleQueue.poll() returns null,
that is the indication if a terminated stream. Downstream should not call Flow.Subscription.request(long)
in this mode. In this mode, the upstream won't call the onXXX methods.
In asynchronous fusion, upstream values may become available to SimpleQueue.poll() eventually.
Upstream signals onError() and onComplete() as usual, however,
onNext will be called with null instead of the actual value.
Downstream should treat such onNext as indication that SimpleQueue.poll() can be called.
In this mode, the downstream still has to call Flow.Subscription.request(long)
to indicate it is prepared to receive more values.
The general rules for consuming the SimpleQueue interface:
-
SimpleQueue.poll()andSimpleQueue.clear()has to be called sequentially (from within a serializing drain-loop). - In addition, callers of
SimpleQueue.poll()should be prepared to catch exceptions. - Due to how computation attaches to the
SimpleQueue.poll(),SimpleQueue.poll()may returnnulleven if a precedingSimpleQueue.isEmpty()returned false.
Implementations should only allow calling the following methods and the rest of the
SimpleQueue interface methods should throw UnsupportedOperationException:
- Since:
- 3.1.1
- See Also:
-
Field Summary
-
Method Summary
Methods inherited from interface Flow.Subscription
cancel, requestMethods inherited from interface QueueFuseable
requestFusion