-
Notifications
You must be signed in to change notification settings - Fork 534
Rule 3.1 vs asynchronous calls #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi David, Have you had a look at the example implementations of publishers and Personally I have not seen any need for what you describe, is it an artifact of how you have decided to implement the spec?Cheers,
|
The examples are a bit hard to read with all those validations (I've introduced a Conformance class to keep all behavior and text in the same place). What I could make out from the examples is that it is intertwined with scheduling the events on an Executor, we have this factored out in Rx* into observeOn. The other thing I've noticed is that |
On 2 Mar 2015 22:01, "David Karnok" [email protected] wrote:
I'm surprised that they are hard to read give the considerable amount of
Not intertwined: the assumption is that the Publisher and the Subscriber
Interesting. I'll have a look when I am back from my vacation. Thanks for
Mandating verbatim exception messages is hard because internationalisation
|
2.12: "Subscriber.onSubscribe MUST be called at most once for a given Subscriber (based on object equality)." This does not say that subsequent calls be ignored.
Yes, did you see: https://github.com/reactive-streams/reactive-streams-jvm/blob/master/examples/src/main/java/org/reactivestreams/example/unicast/SyncSubscriber.java#L21
The stack trace will point to what's null but adding a message is certainly possible, we need to keep in mind that it is an example. The above aside, is there anything here that is unaddressed, if so, please let us know! |
That's all for now. |
Thanks for raising these questions, we clearly have more to do in order to communicate clearly how things are dealt with |
"Subscriber context" feels a bit vague. While reimplementing RxJava to be natively
j.u.c.Flow
(and RS compliant), I found that most non-trivialSubscription
s (subscriptions just wrapping otherSubscription
s or applying a function to the requested amount) either have to serialize access torequest()
andcancel
methods or be completely thread-safe.For example, consider a takeUntil() operator which let's onNext events through until a specified time elapsed. The timeout most likely triggered from another thread in which case the
Subscription.cancel
needs to be invoked asynchronously.If I interpret §3.1 strictly, one could only set a terminal flag on the operator's
Subscriber
to indicate it should drop any further values and cancel the subscription from itsonNext
method the next time a value comes from upstream. This approach, however, delays the upstream cancellation indefinitely and requires serializing access to the downstream'sSubscriber
anyway.I'd say
Subscription.request
andSubscription.cancel
MUST be called in serialized fashion in respect to each other.Given the rest of the rules, I'd also say the most basic/efficient, rule-abiding Subscription implementation is built around a
volatile long
counter: negative value means cancelled, zero means nothing requested yet an positive value is a pending request.The text was updated successfully, but these errors were encountered: