Merge branch 'nickcraver/cancellation' into dev
This commit is contained in:
commit
983997ab9c
|
|
@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Filter
|
||||||
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken token)
|
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken token)
|
||||||
{
|
{
|
||||||
var segment = new ArraySegment<byte>(buffer, offset, count);
|
var segment = new ArraySegment<byte>(buffer, offset, count);
|
||||||
return _output.WriteAsync(segment);
|
return _output.WriteAsync(segment, cancellationToken: token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Flush()
|
public override void Flush()
|
||||||
|
|
|
||||||
|
|
@ -349,7 +349,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
public async Task FlushAsync(CancellationToken cancellationToken)
|
public async Task FlushAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await ProduceStartAndFireOnStarting(immediate: false);
|
await ProduceStartAndFireOnStarting(immediate: false);
|
||||||
await SocketOutput.WriteAsync(_emptyData, immediate: true);
|
await SocketOutput.WriteAsync(_emptyData, immediate: true, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(ArraySegment<byte> data)
|
public void Write(ArraySegment<byte> data)
|
||||||
|
|
|
||||||
|
|
@ -68,14 +68,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
return ((Task<int>)asyncResult).Result;
|
return ((Task<int>)asyncResult).Result;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
private Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken, object state)
|
||||||
{
|
|
||||||
return _body.ReadAsync(new ArraySegment<byte>(buffer, offset, count), cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken, object state)
|
|
||||||
{
|
{
|
||||||
var tcs = new TaskCompletionSource<int>(state);
|
var tcs = new TaskCompletionSource<int>(state);
|
||||||
var task = _body.ReadAsync(new ArraySegment<byte>(buffer, offset, count), cancellationToken);
|
var task = _body.ReadAsync(new ArraySegment<byte>(buffer, offset, count), cancellationToken);
|
||||||
|
|
@ -94,9 +88,15 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
tcs2.SetResult(task2.Result);
|
tcs2.SetResult(task2.Result);
|
||||||
}
|
}
|
||||||
}, tcs);
|
}, tcs, cancellationToken);
|
||||||
return tcs.Task;
|
return tcs.Task;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return _body.ReadAsync(new ArraySegment<byte>(buffer, offset, count), cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Write(byte[] buffer, int offset, int count)
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue