Remove async from WriteAsync in SocketOutput (#1531)

- SocketOutput.WriteAsync will be synchronous for a majority of cases
(until you reach the limit) so no need to pay the async state machine
cost until then.
This commit is contained in:
David Fowler 2017-03-21 09:52:24 -07:00 committed by GitHub
parent 32d6b42964
commit 5fad3c7a3e
1 changed files with 4 additions and 4 deletions

View File

@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
_onFlushCallback = OnFlush; _onFlushCallback = OnFlush;
} }
public async Task WriteAsync( public Task WriteAsync(
ArraySegment<byte> buffer, ArraySegment<byte> buffer,
CancellationToken cancellationToken, CancellationToken cancellationToken,
bool chunk = false) bool chunk = false)
@ -72,12 +72,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
{ {
_log.ConnectionDisconnectedWrite(_connectionId, buffer.Count, _lastWriteError); _log.ConnectionDisconnectedWrite(_connectionId, buffer.Count, _lastWriteError);
return; return TaskCache.CompletedTask;
} }
if (_completed) if (_completed)
{ {
return; return TaskCache.CompletedTask;
} }
writableBuffer = _pipe.Writer.Alloc(); writableBuffer = _pipe.Writer.Alloc();
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
writableBuffer.Commit(); writableBuffer.Commit();
} }
await FlushAsync(writableBuffer); return FlushAsync(writableBuffer);
} }
public void End(ProduceEndType endType) public void End(ProduceEndType endType)