Skip to content

Commit bcd44bf

Browse files
eduardo-vpstephentoubjkotas
authored
Remove ThreadPool native implementation (#71719)
* Remove UsePortableThreadPool() and UsePortableThreadPoolForIO() * Delete win32threadpool.cpp and win32threadpool.h * Delete hillclimbing stuff in function GetThreadpoolData in request.cpp * Delete TPIndex Co-authored-by: Stephen Toub <[email protected]> Co-authored-by: Jan Kotas <[email protected]>
1 parent ca6bbf1 commit bcd44bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+72
-9078
lines changed

src/coreclr/System.Private.CoreLib/src/System/Threading/Overlapped.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,6 @@
2525

2626
namespace System.Threading
2727
{
28-
#region class _IOCompletionCallback
29-
30-
internal sealed unsafe partial class _IOCompletionCallback
31-
{
32-
// call back helper
33-
internal static void PerformIOCompletionCallback(uint errorCode, uint numBytes, NativeOverlapped* pNativeOverlapped)
34-
{
35-
do
36-
{
37-
OverlappedData overlapped = OverlappedData.GetOverlappedFromNative(pNativeOverlapped);
38-
39-
if (overlapped._callback is IOCompletionCallback iocb)
40-
{
41-
// We got here because of UnsafePack (or) Pack with EC flow suppressed
42-
iocb(errorCode, numBytes, pNativeOverlapped);
43-
}
44-
else
45-
{
46-
// We got here because of Pack
47-
var helper = (_IOCompletionCallback?)overlapped._callback;
48-
Debug.Assert(helper != null, "Should only be receiving a completion callback if a delegate was provided.");
49-
helper._errorCode = errorCode;
50-
helper._numBytes = numBytes;
51-
helper._pNativeOverlapped = pNativeOverlapped;
52-
ExecutionContext.RunInternal(helper._executionContext, IOCompletionCallback_Context_Delegate, helper);
53-
}
54-
55-
// Quickly check the VM again, to see if a packet has arrived.
56-
OverlappedData.CheckVMForIOPacket(out pNativeOverlapped, out errorCode, out numBytes);
57-
} while (pNativeOverlapped != null);
58-
}
59-
}
60-
61-
#endregion class _IOCompletionCallback
62-
6328
#region class OverlappedData
6429

6530
internal sealed unsafe class OverlappedData
@@ -120,9 +85,6 @@ internal sealed unsafe class OverlappedData
12085

12186
[MethodImpl(MethodImplOptions.InternalCall)]
12287
internal static extern OverlappedData GetOverlappedFromNative(NativeOverlapped* nativeOverlappedPtr);
123-
124-
[MethodImpl(MethodImplOptions.InternalCall)]
125-
internal static extern void CheckVMForIOPacket(out NativeOverlapped* pNativeOverlapped, out uint errorCode, out uint numBytes);
12688
}
12789

12890
#endregion class OverlappedData

src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,6 @@ internal void ResetThreadPoolThread()
356356
Debug.Assert(this == CurrentThread);
357357
Debug.Assert(IsThreadPoolThread);
358358

359-
if (!ThreadPool.UsePortableThreadPool)
360-
{
361-
// Currently implemented in unmanaged method Thread::InternalReset and
362-
// called internally from the ThreadPool in NotifyWorkItemComplete.
363-
return;
364-
}
365-
366359
if (_mayNeedResetForThreadPool)
367360
{
368361
ResetThreadPoolThreadSlow();

src/coreclr/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.Windows.cs

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,19 @@ public static unsafe bool UnsafeQueueNativeOverlapped(NativeOverlapped* overlapp
1818
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.overlapped);
1919
}
2020

21-
if (UsePortableThreadPoolForIO)
22-
{
23-
// OS doesn't signal handle, so do it here
24-
overlapped->InternalLow = IntPtr.Zero;
25-
26-
PortableThreadPool.ThreadPoolInstance.QueueNativeOverlapped(overlapped);
27-
return true;
28-
}
21+
// OS doesn't signal handle, so do it here
22+
overlapped->InternalLow = IntPtr.Zero;
2923

30-
return PostQueuedCompletionStatus(overlapped);
24+
PortableThreadPool.ThreadPoolInstance.QueueNativeOverlapped(overlapped);
25+
return true;
3126
}
3227

33-
[MethodImpl(MethodImplOptions.InternalCall)]
34-
private static extern unsafe bool PostQueuedCompletionStatus(NativeOverlapped* overlapped);
35-
3628
[Obsolete("ThreadPool.BindHandle(IntPtr) has been deprecated. Use ThreadPool.BindHandle(SafeHandle) instead.")]
3729
[SupportedOSPlatform("windows")]
3830
public static bool BindHandle(IntPtr osHandle)
3931
{
40-
if (UsePortableThreadPoolForIO)
41-
{
42-
PortableThreadPool.ThreadPoolInstance.RegisterForIOCompletionNotifications(osHandle);
43-
return true;
44-
}
45-
46-
return BindIOCompletionCallbackNative(osHandle);
32+
PortableThreadPool.ThreadPoolInstance.RegisterForIOCompletionNotifications(osHandle);
33+
return true;
4734
}
4835

4936
[SupportedOSPlatform("windows")]
@@ -56,22 +43,14 @@ public static bool BindHandle(SafeHandle osHandle)
5643
{
5744
osHandle.DangerousAddRef(ref mustReleaseSafeHandle);
5845

59-
if (UsePortableThreadPoolForIO)
60-
{
61-
PortableThreadPool.ThreadPoolInstance.RegisterForIOCompletionNotifications(osHandle.DangerousGetHandle());
62-
return true;
63-
}
64-
65-
return BindIOCompletionCallbackNative(osHandle.DangerousGetHandle());
46+
PortableThreadPool.ThreadPoolInstance.RegisterForIOCompletionNotifications(osHandle.DangerousGetHandle());
47+
return true;
6648
}
6749
finally
6850
{
6951
if (mustReleaseSafeHandle)
7052
osHandle.DangerousRelease();
7153
}
7254
}
73-
74-
[MethodImpl(MethodImplOptions.InternalCall)]
75-
private static extern bool BindIOCompletionCallbackNative(IntPtr fileHandle);
7655
}
7756
}

0 commit comments

Comments
 (0)