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

Commit ddcaf34

Browse files
stephentoubdotnet-bot
authored andcommitted
Merge pull request dotnet/coreclr#14178 from stephentoub/async_avoid_delegate
Avoid async method delegate allocation Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
1 parent 5a39b52 commit ddcaf34

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Common/src/CoreLib/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public struct ConfiguredValueTaskAwaiter : ICriticalNotifyCompletion
3939
/// <summary>The value being awaited.</summary>
4040
private ValueTask<TResult> _value; // Methods are called on this; avoid making it readonly so as to avoid unnecessary copies
4141
/// <summary>The value to pass to ConfigureAwait.</summary>
42-
private readonly bool _continueOnCapturedContext;
42+
internal readonly bool _continueOnCapturedContext;
4343

4444
/// <summary>Initializes the awaiter.</summary>
4545
/// <param name="value">The value to be awaited.</param>
@@ -66,6 +66,9 @@ public void OnCompleted(Action continuation) =>
6666
/// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable{TResult}"/>.</summary>
6767
public void UnsafeOnCompleted(Action continuation) =>
6868
_value.AsTask().ConfigureAwait(_continueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
69+
70+
/// <summary>Gets the task underlying <see cref="_value"/>.</summary>
71+
internal Task<TResult> AsTask() => _value.AsTask();
6972
}
7073
}
7174
}

src/Common/src/CoreLib/System/Runtime/CompilerServices/ValueTaskAwaiter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ public void OnCompleted(Action continuation) =>
3333
/// <summary>Schedules the continuation action for this ValueTask.</summary>
3434
public void UnsafeOnCompleted(Action continuation) =>
3535
_value.AsTask().ConfigureAwait(continueOnCapturedContext: true).GetAwaiter().UnsafeOnCompleted(continuation);
36+
37+
/// <summary>Gets the task underlying <see cref="_value"/>.</summary>
38+
internal Task<TResult> AsTask() => _value.AsTask();
3639
}
3740
}

0 commit comments

Comments
 (0)