-
Notifications
You must be signed in to change notification settings - Fork 534
3.5 Why is thread-safety of Subscription.cancel() required? #319
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
Experience with RxJava 2, Rsc and Reactor indicates that rule 2.7 adds unnecessary burden because cancels can happen from any thread and in any numbers. For example, a timeout cancels a stream that is cancelled by a limiting operator at the same time. In contrast, making |
@akarnokd Why would it be a burden, all which is required is to wrap the original Subscription in a safe wrapper? Or did I misunderstand? |
It's not only the wrapping but the serialization primitive overhead. Plus the hundreds of operators I've written, the thread-safe cancellation was an easy / trivial thing (see linked by the examples). |
@akarnokd Yes, threadsafe cancellation is "easy", however, should the spec mandate how it is implemented? Or what do you propose given your experience? |
Drop §2.7. §3.5 is fine by itself. |
@akarnokd §2.7 covers more than |
AFAIR addressed by #339 |
Rule 3.5 says that Subscription.cancel() MUST be thread-safe.
Why is this so, given that rule 2.7 excludes the possibility of Subscription.cancel() being invoked concurrently? Why isn't it sufficient if the fact of cancellation is guaranteed to be visible to any subsequent calls on the Subscription?
For example, say I have something like the following:
Why isn't this allowed?
The text was updated successfully, but these errors were encountered: