-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Consolidate Interlocked initialize implementations #69017
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Initialization calls where the initialized value is null and the uninitialized value is non-null became ambiguous once additional initialization patterns were implemented. Since this is only used in one situation in each of C# and VB compilers, we resolve it by providing an explicit argument name for the initialized value.
@dotnet/roslyn-compiler for second review |
1 similar comment
@dotnet/roslyn-compiler for second review |
@@ -1549,7 +1549,7 @@ internal override ObsoleteAttributeData ObsoleteAttributeData | |||
{ | |||
var result = uncommonFields._lazyObsoleteAttributeData; | |||
return ReferenceEquals(result, ObsoleteAttributeData.Uninitialized) | |||
? InterlockedOperations.Initialize(ref uncommonFields._lazyObsoleteAttributeData, null, ObsoleteAttributeData.Uninitialized) | |||
? InterlockedOperations.Initialize(ref uncommonFields._lazyObsoleteAttributeData, initializedValue: null, ObsoleteAttributeData.Uninitialized) |
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.
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.
I couldn't find any overlap/conflict
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.
I think there actually isn't any. I think the linked PR is using Interlocked.CompareExchange, not any InterlockedOperations or similar APIs that changed in this PR.
LazyInitialization
intoInterlockedOperations
(RoslynLazyInitializer
was not appropriate as that type is a mirror ofLazyInitializer
for nullable reference types support)Initialize
) and clarity (helper method namedGetOrStore
)