-
Notifications
You must be signed in to change notification settings - Fork 756
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
BehaviorSubject not eventually consistent? #38
Comments
RxJava fixed this issue with the mentioned mechanism (queue inside a lock to maintain order, have the first producer drain the concurrency queue outside the lock until it's empty). It's a potentially breaking change though, in that sending a new value may be queued instead of completing inline. |
You can do this lock-free. Instead of a plain queue, use a linked-node structure with volatile next pointers. Each subscribing Observer gets a manager Object that picks the current head of the linked structure and walks the nodes until their end; doing it while in a so-called drain-mode. The role of the outer |
|
Copied from https://rx.codeplex.com/workitem/61
I noticed that BehaviorSubject doesn't hold a lock while it sends notifications. I assume this is to avoid some subtle deadlocks, but now there's no mechanism present to prevent notifications from being re-ordered.
I always assumed that subscribing to BehaviorSubject was eventually consistent with respect to the latest value. That the latest notification was the latest value. So...
◾Is that not the case?
◾Is that intentional?
◾What about enqueueing things to notify (while holding the lock) then draining the queue (outside the lock)?
The text was updated successfully, but these errors were encountered: