Transport.Sockets.IOQueue -> IThreadPoolWorkItem (#4601)

This commit is contained in:
Ben Adams 2018-12-27 18:46:53 +00:00 committed by Pavel Krymets
parent 8be8e0008d
commit 0d9de4991e
1 changed files with 3 additions and 5 deletions

View File

@ -8,10 +8,8 @@ using System.Threading;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
{
public class IOQueue : PipeScheduler
public class IOQueue : PipeScheduler, IThreadPoolWorkItem
{
private static readonly WaitCallback _doWorkCallback = s => ((IOQueue)s).DoWork();
private readonly object _workSync = new object();
private readonly ConcurrentQueue<Work> _workItems = new ConcurrentQueue<Work>();
private bool _doingWork;
@ -30,13 +28,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
{
if (!_doingWork)
{
System.Threading.ThreadPool.UnsafeQueueUserWorkItem(_doWorkCallback, this);
System.Threading.ThreadPool.UnsafeQueueUserWorkItem(this, preferLocal: false);
_doingWork = true;
}
}
}
private void DoWork()
void IThreadPoolWorkItem.Execute()
{
while (true)
{