profile
viewpoint

Ask questionsSubscription.cancel MUST BE thread-safe

Rule 3.5

Subscription.cancel MUST respect the responsivity of its caller by returning in a timely manner, MUST be idempotent and MUST be thread-safe.

mentions thread-safety and also links the keyword to it's definition in this context, which mentions "async".

Can be safely invoked synchronously, or asychronously, without requiring external synchronization to ensure program correctness.

The rule seems to contradict other rules, like:

  • 2.7

A Subscriber MUST ensure that all calls on its Subscription's request and cancel methods are performed serially.

  • 3.1

Subscription.request and Subscription.cancel MUST only be called inside of its Subscriber context.

And lastly the "MUST be thread-safe" doesn't equally apply to 'Subscription.request'. Is this obsolete, or is my understanding wrong?

reactive-streams/reactive-streams-jvm

Answer questions tkountis

Thanks for the prompt response 👍 I do understand the 'serially' part, however the fact that Subscription methods end up thread-safe is not the point. My argument is, that the spec defines that cancel must be 'thread-safe', which isn't necessary true, likewise for request which doesn't list this clause. Shouldn't this part be removed or re-worded for clarity?

useful!

Related questions

No questions were found.
source:https://uonfu.com/
Github User Rank List