From ec8d21c434a39f46518ee9cf9f5539d1790eacc0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 4 Nov 2014 00:55:48 +0000 Subject: Label all threadpool calls being made in core OpenSimulator. This is to add problem diagnosis. "show threadpool calls" now also returns named (labelled), anonymous (unlabelled) and total call stats. --- OpenSim/Framework/Util.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Util.cs') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 53bbb06..baad0b9 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1928,11 +1928,6 @@ namespace OpenSim.Framework } } - public static void FireAndForget(System.Threading.WaitCallback callback) - { - FireAndForget(callback, null, null); - } - public static void InitThreadPool(int minThreads, int maxThreads) { if (maxThreads < 2) @@ -1977,8 +1972,7 @@ namespace OpenSim.Framework throw new NotImplementedException(); } } - - + /// /// Additional information about threads in the main thread pool. Used to time how long the /// thread has been running, and abort it if it has timed-out. @@ -2052,10 +2046,10 @@ namespace OpenSim.Framework } } - private static long nextThreadFuncNum = 0; private static long numQueuedThreadFuncs = 0; private static long numRunningThreadFuncs = 0; + private static long numTotalThreadFuncsCalled = 0; private static Int32 threadFuncOverloadMode = 0; // Maps (ThreadFunc number -> Thread) @@ -2086,20 +2080,29 @@ namespace OpenSim.Framework } } + public static long TotalFireAndForgetCallsMade { get { return numTotalThreadFuncsCalled; } } + public static Dictionary GetFireAndForgetCallsMade() { return new Dictionary(m_fireAndForgetCallsMade); - } + } private static Dictionary m_fireAndForgetCallsMade = new Dictionary(); + public static void FireAndForget(System.Threading.WaitCallback callback) + { + FireAndForget(callback, null, null); + } + public static void FireAndForget(System.Threading.WaitCallback callback, object obj) { FireAndForget(callback, obj, null); } - + public static void FireAndForget(System.Threading.WaitCallback callback, object obj, string context) { + Interlocked.Increment(ref numTotalThreadFuncsCalled); + if (context != null) { if (!m_fireAndForgetCallsMade.ContainsKey(context)) -- cgit v1.1