Open OlegDokuka opened 3 years ago
This needs an experiment. Can we relax the safeguards in operators, and instead safe-wrap downstream Subscriber
s if they're not from the vanilla operators CoreSubscriber
?
If yes, can we extend that to non-vanilla CoreSubscriber
s?
Related effort to strictly define fusion for processors: #2626
At the moment we have unconsolidated behaviors in the operators' fusion, which exposed how downstream (a.k.a Queue Drainer) notifies upstream (a.k.a Queue Source) about completion on doing any operators with a queue. This consolidation is even more important in the light when all the elements from the queue MUST be discarded.
This issue stands for providing a clear contract between upstream and downstream in case of fusion between them:
If Fusion established then:
poll
orclear
on its queue until it is notified that downstream is not working with that queue.clear
call, must discard all the elements from the queue if the queue is known as finitequeueSubscription.clear
method that it is done with all operation on that queue and will never call thepoll
method anymorequeueSubscription.clear
only once and ensure it is never called concurrently.queueSubscription.clear
after reception of any of the terminal signals which are (ON_ERROR, ON_COMPLETE, and CANCEL)if Fusion not established then:
By consolidating the behaviors, we will be able to resolve a list of issues related to cases when downstream try to blindly discard elements from the upstream's queue without full context: