Use AsyncTaskCache in ValueTask.AsTask()
authorStephen Toub <stoub@microsoft.com>
Mon, 11 Sep 2017 21:40:57 +0000 (14:40 -0700)
committerStephen Toub <stoub@microsoft.com>
Mon, 11 Sep 2017 21:40:57 +0000 (14:40 -0700)
commiteb9bfb1607bcb7f681ca3eda670982b16fec96c7
tree4bca3254196bf1162fbc3a1290b216cdffcd4565
parent35a8c82f0ab9fe2e9ee8974ecca01e317b467800
Use AsyncTaskCache in ValueTask.AsTask()

We can avoid task allocations for common values by using the same task cache that async methods do.  This is important to avoid allocations in certain cases when switching from Task-returning to ValueTask-returning methods.  If at some point we change Task.FromResult to use the same cache, this can be reverted.
src/mscorlib/shared/System/Threading/Tasks/ValueTask.cs
src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs