-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Fixed lazy loading thread safety #35529
Conversation
- Added sync for lazy loading Fixes #35528
@dotnet-policy-service agree |
Added tests for lazy loading thread safety
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.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
@henriquewr Could you explain what the issue in the original code was? It seems that it made some incorrect assumption, but I don't see what it was exactly |
Oh, I see. While it prevented a second thread from loading it didn't make it wait for the first thread to finish. |
@AndriySvyryd Exacly that what i was going to say |
fixed async lazy loading
|
||
if (exists) | ||
{ | ||
if (isLoadingValue.Depth.Value == 1) |
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.
This is an interesting optimization. It definitely warrants a comment on how it works as the next person to read this code will be very confused.
@roji @cincuranet What's your opinion of this usage of AsyncLocal
?
Thanks for your contribution! |
You're welcome, I'm happy to contribute |
Added sync for lazy loading
Fixes #35528