From c0a00cd7fd887190db61b1c69fb0e8f104a7e438 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 17 Jun 2013 23:34:09 +0100
Subject: Fix bug where no threadpool data would be displayed in the "show
threads" command if threadpool type was QueueUserWorkItem (Unsafe worked as
expected)
---
OpenSim/Framework/Util.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Framework/Util.cs')
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 7f0850f..5e5eb7e 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1880,7 +1880,7 @@ namespace OpenSim.Framework
}
}
else if (
- FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem
+ FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem
|| FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
{
threadPoolUsed = "BuiltInThreadPool";
--
cgit v1.1
From b7c9dee033bad425870540c08832058ac86d4ab5 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 17 Jun 2013 23:57:10 +0100
Subject: refactor: Move existing code to generate report information on the
threadpool to the ServerBase rather than being in Util
---
OpenSim/Framework/Util.cs | 104 ++++++++++++++++++----------------------------
1 file changed, 41 insertions(+), 63 deletions(-)
(limited to 'OpenSim/Framework/Util.cs')
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 5e5eb7e..ba6cc75 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -89,9 +89,30 @@ namespace OpenSim.Framework
}
///
+ /// Class for delivering SmartThreadPool statistical information
+ ///
+ ///
+ /// We do it this way so that we do not directly expose STP.
+ ///
+ public class STPInfo
+ {
+ public string Name { get; set; }
+ public STPStartInfo STPStartInfo { get; set; }
+ public WIGStartInfo WIGStartInfo { get; set; }
+ public bool IsIdle { get; set; }
+ public bool IsShuttingDown { get; set; }
+ public int MaxThreads { get; set; }
+ public int MinThreads { get; set; }
+ public int InUseThreads { get; set; }
+ public int ActiveThreads { get; set; }
+ public int WaitingCallbacks { get; set; }
+ public int MaxConcurrentWorkItems { get; set; }
+ }
+
+ ///
/// Miscellaneous utility functions
///
- public class Util
+ public static class Util
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -1852,74 +1873,31 @@ namespace OpenSim.Framework
}
///
- /// Get a thread pool report.
+ /// Get information about the current state of the smart thread pool.
///
- ///
- public static string GetThreadPoolReport()
+ ///
+ /// null if this isn't the pool being used for non-scriptengine threads.
+ ///
+ public static STPInfo GetSmartThreadPoolInfo()
{
- string threadPoolUsed = null;
- int maxThreads = 0;
- int minThreads = 0;
- int allocatedThreads = 0;
- int inUseThreads = 0;
- int waitingCallbacks = 0;
- int completionPortThreads = 0;
-
- StringBuilder sb = new StringBuilder();
- if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
- {
- // ROBUST currently leaves this the FireAndForgetMethod but never actually initializes the threadpool.
- if (m_ThreadPool != null)
- {
- threadPoolUsed = "SmartThreadPool";
- maxThreads = m_ThreadPool.MaxThreads;
- minThreads = m_ThreadPool.MinThreads;
- inUseThreads = m_ThreadPool.InUseThreads;
- allocatedThreads = m_ThreadPool.ActiveThreads;
- waitingCallbacks = m_ThreadPool.WaitingCallbacks;
- }
- }
- else if (
- FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem
- || FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
- {
- threadPoolUsed = "BuiltInThreadPool";
- ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads);
- ThreadPool.GetMinThreads(out minThreads, out completionPortThreads);
- int availableThreads;
- ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads);
- inUseThreads = maxThreads - availableThreads;
- allocatedThreads = -1;
- waitingCallbacks = -1;
- }
+ if (m_ThreadPool == null)
+ return null;
- if (threadPoolUsed != null)
- {
- sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed);
- sb.AppendFormat("Max threads : {0}\n", maxThreads);
- sb.AppendFormat("Min threads : {0}\n", minThreads);
- sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString());
- sb.AppendFormat("In use threads : {0}\n", inUseThreads);
- sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString());
- }
- else
- {
- sb.AppendFormat("Thread pool not used\n");
- }
+ STPInfo stpi = new STPInfo();
+ stpi.Name = m_ThreadPool.Name;
+ stpi.STPStartInfo = m_ThreadPool.STPStartInfo;
+ stpi.IsIdle = m_ThreadPool.IsIdle;
+ stpi.IsShuttingDown = m_ThreadPool.IsShuttingdown;
+ stpi.MaxThreads = m_ThreadPool.MaxThreads;
+ stpi.MinThreads = m_ThreadPool.MinThreads;
+ stpi.InUseThreads = m_ThreadPool.InUseThreads;
+ stpi.ActiveThreads = m_ThreadPool.ActiveThreads;
+ stpi.WaitingCallbacks = m_ThreadPool.WaitingCallbacks;
+ stpi.MaxConcurrentWorkItems = m_ThreadPool.Concurrency;
- return sb.ToString();
+ return stpi;
}
-// private static object SmartThreadPoolCallback(object o)
-// {
-// object[] array = (object[])o;
-// WaitCallback callback = (WaitCallback)array[0];
-// object obj = array[1];
-//
-// callback(obj);
-// return null;
-// }
-
#endregion FireAndForget Threading Pattern
///
--
cgit v1.1