Skip to content
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

4.x: Improve RefCount() internals #774

Merged
merged 3 commits into from
Jul 6, 2018

Conversation

akarnokd
Copy link
Collaborator

@akarnokd akarnokd commented Jul 6, 2018

This PR adds a dedicated connection state object to avoid reconnection and disconnection interference as well as some comments about what each part of the algorithm does.

(Note: it does not add the unit test from #773 as it is unclear to me that unit test is supposed to ensure, an old or new behavior?).

@danielcweber
Copy link
Collaborator

danielcweber commented Jul 6, 2018

The purpose of that unit test was to ensure that, should base.Run(...) dispose the Sink synchronously, it will be discovered and the call to Connect will be avoided.

@akarnokd
Copy link
Collaborator Author

akarnokd commented Jul 6, 2018

Only in the synchronous case? What about an async completing source? Should we detect any termination and prevent further connections?

@danielcweber
Copy link
Collaborator

I guess 99% of the time RefCount will deal with some Subject, and once that is completed, the notification will come in synchronously. I don't think there is enough reason to cover more complex scenarios.

// only the currently known connection is affected
// and a connection from a concurrent reconnection won't
// interfere
Disposable.SetSingle(ref conn._disposable, _parent._source.Connect());
Copy link
Collaborator

@danielcweber danielcweber Jul 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked it with the unit test from #773 and it's red. It should be enough to guard this by if (!Disposable.GetIsDisposed(ref conn._disposable)) to avoid connecting and immediately disconnecting.

@danielcweber danielcweber merged commit b37fb94 into dotnet:master Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants