From 1f0bb14546a41ec9b03294df3874206099b52f0b Mon Sep 17 00:00:00 2001 From: David Fowler Date: Wed, 8 Mar 2017 08:43:11 -0800 Subject: [PATCH] Clean up left over code from port to pipelines (#1465) - Remove unused methods in PipelineExtensions - Remove AwaitableThreadPool since we dispatch reads --- .../Internal/Http/PipelineExtensions.cs | 20 ---------- .../Infrastructure/AwaitableThreadPool.cs | 39 ------------------- 2 files changed, 59 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/AwaitableThreadPool.cs diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipelineExtensions.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipelineExtensions.cs index a37670cfa6..1a014aff56 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipelineExtensions.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipelineExtensions.cs @@ -4,9 +4,7 @@ using System; using System.IO.Pipelines; using System.Runtime.CompilerServices; -using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure; namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http { @@ -48,8 +46,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http { var result = await readingTask; - await AwaitableThreadPool.Yield(); - try { if (!result.Buffer.IsEmpty) @@ -71,13 +67,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http } } - private static async Task ReadAsyncDispatchedAwaited(ReadableBufferAwaitable awaitable) - { - var result = await awaitable; - await AwaitableThreadPool.Yield(); - return result; - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span ToSpan(this ReadableBuffer buffer) { @@ -88,15 +77,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http return buffer.ToArray(); } - public static ArraySegment ToArraySegment(this ReadableBuffer buffer) - { - if (buffer.IsSingleSpan) - { - return buffer.First.GetArray(); - } - return new ArraySegment(buffer.ToArray()); - } - public static ArraySegment GetArray(this Memory memory) { ArraySegment result; diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/AwaitableThreadPool.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/AwaitableThreadPool.cs deleted file mode 100644 index 70930c73ae..0000000000 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/AwaitableThreadPool.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure -{ - internal static class AwaitableThreadPool - { - internal static Awaitable Yield() - { - return new Awaitable(); - } - - internal struct Awaitable : ICriticalNotifyCompletion - { - public void GetResult() - { - - } - - public Awaitable GetAwaiter() => this; - - public bool IsCompleted => false; - - public void OnCompleted(Action continuation) - { - Task.Run(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - OnCompleted(continuation); - } - } - } -} \ No newline at end of file