Enable option to use the Windows ThreadPool (#85373)
authorEduardo Velarde <32459232+eduardo-vp@users.noreply.github.com>
Thu, 15 Jun 2023 01:50:10 +0000 (18:50 -0700)
committerGitHub <noreply@github.com>
Thu, 15 Jun 2023 01:50:10 +0000 (18:50 -0700)
commit0a0fa137097595ad8ec0e2aa9ecffb524cd5df95
tree93d4bd31d3308a676874e6ce3d0af5610de2fa9e
parent226e3ec0ad99ef97b91e8f72c681b9ea7398cb2e
Enable option to use the Windows ThreadPool (#85373)

When running on Windows, enable an option to switch between the Portable thread pool and the Windows thread pool.

This change targets NativeAOT, CoreCLR, and Mono.

Windows threadpool remains as the default for NativeAOT on Windows. For any other case the Portable thread pool remains the default.

Tests with the Windows thread pool enabled were added to the System.Threading.Threadpool solution.

Trimming is enabled to remove the unused thread pool.
---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Koundinya Veluri <kouvel@users.noreply.github.com>
53 files changed:
src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
src/coreclr/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.Windows.cs [deleted file]
src/coreclr/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/ThreadPool.NativeAot.cs [deleted file]
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs [deleted file]
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/ThreadPoolCallbackWrapper.NativeAot.cs [moved from src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/ThreadPoolCallbackWrapper.cs with 100% similarity]
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Win32ThreadPoolPreAllocatedOverlapped.cs [deleted file]
src/coreclr/vm/comthreadpool.cpp
src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Windows.xml [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeThreadPoolIOHandle.cs [moved from src/coreclr/nativeaot/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeThreadPoolIOHandle.cs with 90% similarity]
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Threading/CompleteWaitThreadPoolWorkItem.cs [moved from src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs with 53% similarity]
src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.cs
src/libraries/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.Portable.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.Unix.cs [moved from src/libraries/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.cs with 82% similarity]
src/libraries/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.Windows.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.WindowsThreadPool.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs
src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Unix.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Windows.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.WindowsThreadPool.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.Unix.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.Windows.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Unix.cs [moved from src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs with 53% similarity]
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.Portable.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.Unix.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.Windows.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.WindowsThreadPool.cs [moved from src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Win32ThreadPoolBoundHandle.cs with 74% similarity]
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolCallbackWrapper.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Portable.cs
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Unix.cs
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Windows.cs
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.WindowsThreadPool.cs [moved from src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Timer.Windows.cs with 79% similarity]
src/libraries/System.Private.CoreLib/src/System/Threading/Win32ThreadPoolNativeOverlapped.ExecutionContextCallbackArgs.cs [moved from src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Win32ThreadPoolNativeOverlapped.ExecutionContextCallbackArgs.cs with 78% similarity]
src/libraries/System.Private.CoreLib/src/System/Threading/Win32ThreadPoolNativeOverlapped.OverlappedData.cs [moved from src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Win32ThreadPoolNativeOverlapped.OverlappedData.cs with 89% similarity]
src/libraries/System.Private.CoreLib/src/System/Threading/Win32ThreadPoolNativeOverlapped.cs [moved from src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Win32ThreadPoolNativeOverlapped.cs with 92% similarity]
src/libraries/System.Private.CoreLib/src/System/Threading/WindowsThreadPool.cs [new file with mode: 0644]
src/libraries/System.Runtime/tests/TrimmingTests/System.Runtime.TrimmingTests.proj
src/libraries/System.Runtime/tests/TrimmingTests/UseWindowsThreadPoolFalse.cs [new file with mode: 0644]
src/libraries/System.Runtime/tests/TrimmingTests/UseWindowsThreadPoolTrue.cs [new file with mode: 0644]
src/libraries/System.Threading.ThreadPool/System.Threading.ThreadPool.sln
src/libraries/System.Threading.ThreadPool/tests/System.Threading.ThreadPool.Tests.csproj
src/libraries/System.Threading.ThreadPool/tests/ThreadPoolTests.cs
src/libraries/System.Threading.ThreadPool/tests/WindowsThreadPool/System.Threading.ThreadPool.WindowsThreadPool.Tests.csproj [new file with mode: 0644]
src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj
src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs
src/mono/System.Private.CoreLib/src/System/Threading/TimerQueue.Browser.Mono.cs