From 95b614bf21ddf24ad0c0ccd259f2722583660d73 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 6882b0482c017a..c3716043469492 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 b778de9e0ca326ebd7c9761aabdbee3b6bc182f8 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 c3716043469492..d906842cfc85dd 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 db20ff01c3c1e7b0e08e2c3807016cd758414e39 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 d906842cfc85dd..4309e1f1f7a770 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 734c5004605645a3611cf7180bb73b1066e40d88 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 4309e1f1f7a770..e6a6de11a237ec 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 3f56c8d1cbcaac85b1a11b28d49ce5e1b08f28be 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 e6a6de11a237ec..5d3f45f6ab97d7 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 d55e801ee7c88b5ffdad4f13119836ba55eb3245 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 5d3f45f6ab97d7..0da875498afc18 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;