Don't preserve the ExecutionContext when dispatching callbacks (#2861)
* Don't preserve the ExecutionContext when dispatching callbacks - The layers up stack already preserve and restore the ExecutionContext, there's no need to capture and run for the scheduler callback and cancellation token callback
This commit is contained in:
parent
b039fb73c4
commit
6dc55a0462
|
|
@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Connections
|
|||
|
||||
public override void Abort(ConnectionAbortedException abortReason)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(cts => ((CancellationTokenSource)cts).Cancel(), _connectionClosedTokenSource);
|
||||
ThreadPool.UnsafeQueueUserWorkItem(cts => ((CancellationTokenSource)cts).Cancel(), _connectionClosedTokenSource);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
|
|||
|
||||
public void OnCompleted(Action continuation)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state => ((Action)state)(), continuation);
|
||||
ThreadPool.UnsafeQueueUserWorkItem(state => ((Action)state)(), continuation);
|
||||
}
|
||||
|
||||
public void UnsafeOnCompleted(Action continuation)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
|
||||
// We're done with the socket now
|
||||
_socket.Dispose();
|
||||
ThreadPool.QueueUserWorkItem(state => ((LibuvConnection)state).CancelConnectionClosedToken(), this);
|
||||
ThreadPool.UnsafeQueueUserWorkItem(state => ((LibuvConnection)state).CancelConnectionClosedToken(), this);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
|
|||
{
|
||||
if (!_doingWork)
|
||||
{
|
||||
System.Threading.ThreadPool.QueueUserWorkItem(_doWorkCallback, this);
|
||||
System.Threading.ThreadPool.UnsafeQueueUserWorkItem(_doWorkCallback, this);
|
||||
_doingWork = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
|
|||
|
||||
_receiver.Dispose();
|
||||
_sender.Dispose();
|
||||
ThreadPool.QueueUserWorkItem(state => ((SocketConnection)state).CancelConnectionClosedToken(), this);
|
||||
ThreadPool.UnsafeQueueUserWorkItem(state => ((SocketConnection)state).CancelConnectionClosedToken(), this);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTrans
|
|||
|
||||
_isClosed = true;
|
||||
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
ThreadPool.UnsafeQueueUserWorkItem(state =>
|
||||
{
|
||||
var self = (InMemoryTransportConnection)state;
|
||||
self._connectionClosedTokenSource.Cancel();
|
||||
|
|
|
|||
Loading…
Reference in New Issue