-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Stop collecting disposables if changed token encountered #66265
Stop collecting disposables if changed token encountered #66265
Conversation
Tagging subscribers to this area: @dotnet/area-extensions-primitives Issue Detailsnull
|
Thank you for the PR, @mapogolions. Can you add a description to this PR explaining what the situation is that is not behaving correctly today, and why it isn't behaving correctly? |
Traditional flow:We usually pass a list of tokens that have not yet been changed to the constructor of the composite token.
where: Then we register some callback for the composite token.
at this moment At the output, we have a construct in which the created composite token has not yet been changed If cancellation is requested for one of these tokens
the static OnChange method will be called. What it does:
If cancellation is then requested for the second passed token
The OnChange method will no longer be called as all disposables(registrations) have been disposed. Issue flow:We also pass a list of tokens, but one of them has already been changed.
where: Then we register some callback for the composite token
The static method OnChange will be called at the moment of registration by the line above.
It will trigger the OnChange method again. This PIR is trying to remove redundant work - if we know that the composite token has changed, why do we still keep registering a callback for each token in order to be able to change the composite token in the future |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a couple minor code style changes.
FYI @davidfowl - in case you have any concerns here.
src/libraries/Microsoft.Extensions.Primitives/tests/CompositeChangeTokenTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Primitives/tests/CompositeChangeTokenTest.cs
Outdated
Show resolved
Hide resolved
…hangeTokenTest.cs Co-authored-by: Eric Erhardt <[email protected]>
…hangeTokenTest.cs Co-authored-by: Eric Erhardt <[email protected]>
@eerhardt Thanks for review. I am still working on my English. I would appreciate any of your suggestions for renaming local variables, classes, functions. |
I thought they all looked fine. |
Test failure was #65791. |
No description provided.