Interface QueueDisposable<T>
- Type Parameters:
T- the value type transmitted through the queue
- All Superinterfaces:
AutoCloseable, Disposable, QueueFuseable<T>, SimpleQueue<T>
SimpleQueue and Disposable and allows negotiating
the fusion mode between subsequent operators of the Observable 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. 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.
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
Fields inherited from interface QueueFuseable
ANY, ASYNC, BOUNDARY, NONE, SYNCModifier and TypeFieldDescriptionstatic final intRequest any of theQueueFuseable.SYNCorQueueFuseable.ASYNCmodes.static final intRequest an asynchronous fusion mode and can be returned byQueueFuseable.requestFusion(int)for an accepted mode.static final intUsed in binary or combination with the other constants as an input toQueueFuseable.requestFusion(int)indicating that theSimpleQueue.poll()will be called behind an asynchronous boundary and thus may change the non-trivial computation locations attached to theSimpleQueue.poll()chain of fused operators.static final intReturned by theQueueFuseable.requestFusion(int)if the upstream doesn't support the requested mode.static final intRequest a synchronous fusion mode and can be returned byQueueFuseable.requestFusion(int)for an accepted mode. -
Method Summary
Methods inherited from interface Disposable
close, dispose, isDisposedMethods inherited from interface QueueFuseable
requestFusionModifier and TypeMethodDescriptionintrequestFusion(int mode) Request a fusion mode from the upstream.Methods inherited from interface SimpleQueue
clear, isEmpty, offer, offer, pollModifier and TypeMethodDescriptionvoidclear()Removes all enqueued items from this queue.booleanisEmpty()Returns true if the queue is empty.booleanAtomically enqueue a single value.booleanAtomically enqueue two values.poll()Tries to dequeue a value (non-null) or returns null if the queue is empty.