diff options
author | Stephen Toub <stoub@microsoft.com> | 2018-09-28 20:05:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-28 20:05:29 -0400 |
commit | 7d14e3a60dd9eff95e60b919cf30fd9f306e0e75 (patch) | |
tree | 4a61060317be36a355970f874c68a0fce9247f9e | |
parent | c6ef88d88fe8c95323247393c04e6b161da3bb0e (diff) | |
download | coreclr-7d14e3a60dd9eff95e60b919cf30fd9f306e0e75.tar.gz coreclr-7d14e3a60dd9eff95e60b919cf30fd9f306e0e75.tar.bz2 coreclr-7d14e3a60dd9eff95e60b919cf30fd9f306e0e75.zip |
Avoid allocation in Task.Yield() awaiter (#20186)
Now that IAsyncStateMachineBox is an IThreadPoolWorkItem, we can queue it directly in Task.Yield's awaiter. This makes `await Task.Yield();` allocation-free when the default scheduler is used.
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs index 68fd5ab8d6..f160719cdb 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs @@ -143,7 +143,7 @@ namespace System.Runtime.CompilerServices TaskScheduler scheduler = TaskScheduler.Current; if (scheduler == TaskScheduler.Default) { - ThreadPool.UnsafeQueueUserWorkItem(s => ((IAsyncStateMachineBox)s).MoveNext(), box); + ThreadPool.UnsafeQueueCustomWorkItem(box, forceGlobal: true); } else { |