Conversation
| private void PublicationOnly(LazyHelper publicationOnly, T possibleValue) | ||
| { | ||
| LazyHelper previous = Interlocked.CompareExchange(ref _state, LazyHelper.PublicationOnlyWaitForOtherThreadToPublish, publicationOnly); | ||
| LazyHelper? previous = Interlocked.CompareExchange(ref _state, LazyHelper.PublicationOnlyWaitForOtherThreadToPublish, publicationOnly); |
There was a problem hiding this comment.
Would it be more efficient if it was Interlocked.CompareExchange<LazyHelper>(ref _state, LazyHelper.PublicationOnlyWaitForOtherThreadToPublish, publicationOnly) ?
There was a problem hiding this comment.
Or maybe that doesn't work because you want <LazyHelper?>
There was a problem hiding this comment.
I guess I figured it must be using public static object CompareExchange (ref object location1, object value, object comparand); and on the generic version is noted This method overload is preferable to the CompareExchange(Object, Object, Object) method overload, because the latter requires the destination object to be accessed late-bound. (whatever that means - I assume it means that it has to resolve the overload at runtime?)
But now I see the compiler prefers the generic overload unless the parameter is explicitly of type object.
| { | ||
| return IsValueCreated ? Value.ToString() : SR.Lazy_ToString_ValueNotCreated; | ||
| return IsValueCreated ? | ||
| Value!.ToString() : // TODO-NULLABLE: Documented to throw NullReferenceException |
There was a problem hiding this comment.
TODO because you want to replace it with ANE (and update docs)?
There was a problem hiding this comment.
Maybe. I wanted to flag it to revisit at least.
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <anirudhagnihotry098@gmail.com>
Signed-off-by: dotnet-bot <anirudhagnihotry098@gmail.com>
Signed-off-by: dotnet-bot <anirudhagnihotry098@gmail.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Commit migrated from dotnet/coreclr@e06e85d
No description provided.