From 63ddf270096914314243dbc3e7a00cc2989ceffd Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Aug 2023 13:54:16 -0700 Subject: [PATCH 1/6] Add boolean field to indicate whether or not the Windows thread pool is being used --- .../src/System/Threading/ThreadPool.Windows.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs index 6882b0482c017..c371604346949 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs @@ -13,6 +13,9 @@ public static partial class ThreadPool internal static bool UseWindowsThreadPool { get; } = AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.UseWindowsThreadPool", "DOTNET_ThreadPool_UseWindowsThreadPool"); + // Exposes whether or not the Windows thread pool is used for diagnostics purposes + private static readonly bool s_useWindowsThreadPoolForDebugger = UseWindowsThreadPool; + #if NATIVEAOT private const bool IsWorkerTrackingEnabledInConfig = false; #else From fd8e533881c0c846214c6877a45a44c9979d6f3d Mon Sep 17 00:00:00 2001 From: Eduardo Velarde <32459232+eduardo-vp@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:28:49 -0700 Subject: [PATCH 2/6] Update src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs Co-authored-by: Stephen Toub --- .../src/System/Threading/ThreadPool.Windows.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs index c371604346949..d906842cfc85d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs @@ -10,11 +10,10 @@ namespace System.Threading { public static partial class ThreadPool { - internal static bool UseWindowsThreadPool { get; } = + private static readonly bool s_useWindowsThreadPool = // name relied on by sos AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.UseWindowsThreadPool", "DOTNET_ThreadPool_UseWindowsThreadPool"); - - // Exposes whether or not the Windows thread pool is used for diagnostics purposes - private static readonly bool s_useWindowsThreadPoolForDebugger = UseWindowsThreadPool; + + internal static bool UseWindowsThreadPool => s_useWindowsThreadPool; #if NATIVEAOT private const bool IsWorkerTrackingEnabledInConfig = false; From 149a10a3070e9ee140fd0d8d8a02353c9375dcd5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Aug 2023 18:31:17 -0700 Subject: [PATCH 3/6] Remove trailing spaces --- .../src/System/Threading/ThreadPool.Windows.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs index d906842cfc85d..4309e1f1f7a77 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs @@ -12,7 +12,7 @@ public static partial class ThreadPool { private static readonly bool s_useWindowsThreadPool = // name relied on by sos AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.UseWindowsThreadPool", "DOTNET_ThreadPool_UseWindowsThreadPool"); - + internal static bool UseWindowsThreadPool => s_useWindowsThreadPool; #if NATIVEAOT From 70acf4cf4854e5ca1c01ff09c22a0f0ed5dc8983 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Aug 2023 16:04:21 -0700 Subject: [PATCH 4/6] Move comment --- .../src/System/Threading/ThreadPool.Windows.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs index 4309e1f1f7a77..e6a6de11a237e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs @@ -10,7 +10,8 @@ namespace System.Threading { public static partial class ThreadPool { - private static readonly bool s_useWindowsThreadPool = // name relied on by sos + // name relied on by sos + private static readonly bool s_useWindowsThreadPool = AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.UseWindowsThreadPool", "DOTNET_ThreadPool_UseWindowsThreadPool"); internal static bool UseWindowsThreadPool => s_useWindowsThreadPool; From 0b21daa1cc70c4f840e1ecf12cbe9fea612c8c11 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Aug 2023 16:20:28 -0700 Subject: [PATCH 5/6] Update fields and comments --- .../src/System/Threading/ThreadPool.Windows.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs index e6a6de11a237e..5d3f45f6ab97d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs @@ -10,11 +10,12 @@ namespace System.Threading { public static partial class ThreadPool { - // name relied on by sos - private static readonly bool s_useWindowsThreadPool = + internal static bool UseWindowsThreadPool { get; } = AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.UseWindowsThreadPool", "DOTNET_ThreadPool_UseWindowsThreadPool"); - internal static bool UseWindowsThreadPool => s_useWindowsThreadPool; + // The field should reflect what the property returns because the property can be stubbed by trimming, + // such that sos reflects the actual state of what thread pool is being used and not just the config value. + private static readonly bool s_useWindowsThreadPool = UseWindowsThreadPool; // Name relied on by sos #if NATIVEAOT private const bool IsWorkerTrackingEnabledInConfig = false; From 86fd9ead84d3cd6d4ed164d6561f205352fde358 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Aug 2023 13:26:24 -0700 Subject: [PATCH 6/6] Disable CA1823 - unused field --- .../src/System/Threading/ThreadPool.Windows.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs index 5d3f45f6ab97d..0da875498afc1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs @@ -13,9 +13,11 @@ public static partial class ThreadPool internal static bool UseWindowsThreadPool { get; } = AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.UseWindowsThreadPool", "DOTNET_ThreadPool_UseWindowsThreadPool"); +#pragma warning disable CA1823 // The field should reflect what the property returns because the property can be stubbed by trimming, // such that sos reflects the actual state of what thread pool is being used and not just the config value. private static readonly bool s_useWindowsThreadPool = UseWindowsThreadPool; // Name relied on by sos +#pragma warning restore CA1823 #if NATIVEAOT private const bool IsWorkerTrackingEnabledInConfig = false;