Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Nullable: Lazy#23639

Merged
danmoseley merged 1 commit intodotnet:NullableFeaturefrom
stephentoub:nullablelazy
Apr 2, 2019
Merged

Nullable: Lazy#23639
danmoseley merged 1 commit intodotnet:NullableFeaturefrom
stephentoub:nullablelazy

Conversation

@stephentoub
Copy link
Copy Markdown
Member

No description provided.

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it be more efficient if it was Interlocked.CompareExchange<LazyHelper>(ref _state, LazyHelper.PublicationOnlyWaitForOtherThreadToPublish, publicationOnly) ?

Copy link
Copy Markdown
Member

@danmoseley danmoseley Apr 1, 2019

Choose a reason for hiding this comment

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

Or maybe that doesn't work because you want <LazyHelper?>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

More efficient?

Copy link
Copy Markdown
Member

@danmoseley danmoseley Apr 2, 2019

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TODO because you want to replace it with ANE (and update docs)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe. I wanted to flag it to revisit at least.

@danmoseley danmoseley merged commit e06e85d into dotnet:NullableFeature Apr 2, 2019
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Apr 5, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
stephentoub added a commit to dotnet/corefx that referenced this pull request Apr 6, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Apr 9, 2019
Signed-off-by: dotnet-bot <anirudhagnihotry098@gmail.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Apr 9, 2019
Signed-off-by: dotnet-bot <anirudhagnihotry098@gmail.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request Apr 9, 2019
Signed-off-by: dotnet-bot <anirudhagnihotry098@gmail.com>
Anipik pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Apr 9, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
jkotas pushed a commit to dotnet/corert that referenced this pull request Apr 10, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
@stephentoub stephentoub deleted the nullablelazy branch April 15, 2019 01:29
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants