Make all calls to ThreadPool.QueueUserWorkItem through IThreadPool
- This allows SocketOutputTests to cause QUWI to exec synchronously - To avoid allocations, the logger can't be captured making it "unsafe"
This commit is contained in:
parent
4587a0fc95
commit
0742d113be
|
|
@ -288,7 +288,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
|
||||
if (blockToReturn != null)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(_returnBlocks, blockToReturn);
|
||||
_threadPool.UnsafeRun(_returnBlocks, blockToReturn);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -542,8 +542,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
|
||||
private class WriteContext
|
||||
{
|
||||
private static WaitCallback _returnWrittenBlocks = (state) => ReturnWrittenBlocks((MemoryPoolBlock)state);
|
||||
private static WaitCallback _completeWrite = (state) => ((WriteContext)state).CompleteOnThreadPool();
|
||||
private static readonly WaitCallback _returnWrittenBlocks = (state) => ReturnWrittenBlocks((MemoryPoolBlock)state);
|
||||
private static readonly WaitCallback _completeWrite = (state) => ((WriteContext)state).CompleteOnThreadPool();
|
||||
|
||||
private SocketOutput Self;
|
||||
private UvWriteReq _writeReq;
|
||||
|
|
@ -658,7 +658,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
else
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(_completeWrite, this);
|
||||
Self._threadPool.UnsafeRun(_completeWrite, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -697,7 +697,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
block.Next = null;
|
||||
|
||||
ThreadPool.QueueUserWorkItem(_returnWrittenBlocks, _lockedStart.Block);
|
||||
Self._threadPool.UnsafeRun(_returnWrittenBlocks, _lockedStart.Block);
|
||||
}
|
||||
|
||||
private static void ReturnWrittenBlocks(MemoryPoolBlock block)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
||||
|
|
@ -12,5 +13,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
void Cancel(TaskCompletionSource<object> tcs);
|
||||
void Error(TaskCompletionSource<object> tcs, Exception ex);
|
||||
void Run(Action action);
|
||||
void UnsafeRun(WaitCallback action, object state);
|
||||
}
|
||||
}
|
||||
|
|
@ -63,6 +63,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
ThreadPool.QueueUserWorkItem(_runAction, action);
|
||||
}
|
||||
|
||||
public void UnsafeRun(WaitCallback action, object state)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(action, state);
|
||||
}
|
||||
|
||||
public void Complete(TaskCompletionSource<object> tcs)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(_completeTcs, tcs);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
|
||||
|
|
@ -28,5 +29,10 @@ namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers
|
|||
{
|
||||
action();
|
||||
}
|
||||
|
||||
public void UnsafeRun(WaitCallback action, object state)
|
||||
{
|
||||
action(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue