From cbb3211c12752f695f0f1240b6b60ca6ee46642b Mon Sep 17 00:00:00 2001 From: Michal Staszewski Date: Tue, 21 Jun 2011 14:16:50 +0200 Subject: [PATCH] CHG: threads can be named (cherry picked from commit fbbbc451c9372af2862bc39cdf7698653c611dcf) --- SmartThreadPool/STPStartInfo.cs | 14 ++++++++++++++ SmartThreadPool/SmartThreadPool.cs | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/SmartThreadPool/STPStartInfo.cs b/SmartThreadPool/STPStartInfo.cs index fdab702..d19a1d9 100644 --- a/SmartThreadPool/STPStartInfo.cs +++ b/SmartThreadPool/STPStartInfo.cs @@ -15,6 +15,7 @@ namespace Amib.Threading private string _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName; private bool _areThreadsBackground = SmartThreadPool.DefaultAreThreadsBackground; private bool _enableLocalPerformanceCounters; + private string _threadPoolName = SmartThreadPool.DefaultThreadPoolName; public STPStartInfo() { @@ -34,6 +35,7 @@ namespace Amib.Threading _threadPriority = stpStartInfo.ThreadPriority; _performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName; _enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters; + _threadPoolName = stpStartInfo._threadPoolName; _areThreadsBackground = stpStartInfo.AreThreadsBackground; } @@ -95,6 +97,18 @@ namespace Amib.Threading } } + /// + /// Get/Set the thread pool name. Threads will get names depending on this. + /// + public virtual string ThreadPoolName { + get { return _threadPoolName; } + set + { + ThrowIfReadOnly (); + _threadPoolName = value; + } + } + /// /// Get/Set the performance counter instance name of this SmartThreadPool /// The default is null which indicate not to use performance counters at all. diff --git a/SmartThreadPool/SmartThreadPool.cs b/SmartThreadPool/SmartThreadPool.cs index 9853d72..0801254 100644 --- a/SmartThreadPool/SmartThreadPool.cs +++ b/SmartThreadPool/SmartThreadPool.cs @@ -161,6 +161,11 @@ namespace Amib.Threading /// /// The default fill state with params. (false) + + /// + /// The default thread pool name. (SmartThreadPool) + /// + public const string DefaultThreadPoolName = "SmartThreadPool"; /// It is relevant only to QueueWorkItem of Action<...>/Func<...> /// public const bool DefaultFillStateWithArgs = false; @@ -395,7 +400,7 @@ namespace Amib.Threading private void Initialize() { - Name = "SmartThreadPool"; + Name = _stpStartInfo.ThreadPoolName; ValidateSTPStartInfo(); // _stpStartInfoRW stores a read/write copy of the STPStartInfo.