Change some internal async Task methods to be async ValueTask (dotnet/corefx#40527)
authorStephen Toub <stoub@microsoft.com>
Thu, 10 Oct 2019 10:04:01 +0000 (06:04 -0400)
committerGitHub <noreply@github.com>
Thu, 10 Oct 2019 10:04:01 +0000 (06:04 -0400)
commit6adeb9be609b013e16cc50d435bea9f0eb3bd8e2
tree58ed9990639ff71cb55b7e5c58d8600afeeb95fb
parent08b76ee2b9d09a13adecccbc727f5c9f1b27b7f4
Change some internal async Task methods to be async ValueTask (dotnet/corefx#40527)

We have some internal and private `async Task` methods that are only ever `await`ed.  Today there's no benefit to making them `async ValueTask` methods, so we've kept them as `async Task`.  However, if we end up changing the implementation of `async ValueTask` to pool underlying objects, there becomes a potential benefit to using `async ValueTask` for these instead of `async Task`.  This PR changes those in a variety of libraries where we care more about performance and allocations.  There are likely a few more methods we'd want to convert based on profiling, but I believe this represents the bulk of them.

Commit migrated from https://github.com/dotnet/corefx/commit/97d9fb9d6c7e1d50f527e290ef8e18767dbc6bbf
23 files changed:
src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs
src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/enc/BrotliStream.Compress.cs
src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/DeflateStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingWriteStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ContentLengthReadStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ContentLengthWriteStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/CreditManager.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpContentReadStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpContentWriteStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/TaskCompletionSourceWithCancellation.cs
src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs
src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs
src/libraries/System.Net.Security/tests/UnitTests/Fakes/FakeSslStream.Implementation.cs
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocket.cs
src/libraries/System.Runtime.Extensions/src/System/IO/BufferedStream.cs
src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptoStream.cs
src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelWriter.cs