From 4289b7114198ea8dfb5b5d5134ada1e5582528d9 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 25 Mar 2014 10:04:52 +0200 Subject: Fixed unit tests due to changes in the threadpool --- OpenSim/Framework/Util.cs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Util.cs') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index c9930fb..ae720f1 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -2081,15 +2081,19 @@ namespace OpenSim.Framework try { long numRunning = numRunningThreadFuncs; - if ((threadFuncOverloadMode == 0) && (numRunning >= m_ThreadPool.MaxThreads)) - { - if (Interlocked.CompareExchange(ref threadFuncOverloadMode, 1, 0) == 0) - m_log.DebugFormat("Threadfunc: enable overload mode (Queued {0}, Running {1})", numQueued, numRunning); - } - else if ((threadFuncOverloadMode == 1) && (numRunning <= (m_ThreadPool.MaxThreads*2)/3)) + + if (m_ThreadPool != null) { - if (Interlocked.CompareExchange(ref threadFuncOverloadMode, 0, 1) == 1) - m_log.DebugFormat("Threadfunc: disable overload mode (Queued {0}, Running {1})", numQueued, numRunning); + if ((threadFuncOverloadMode == 0) && (numRunning >= m_ThreadPool.MaxThreads)) + { + if (Interlocked.CompareExchange(ref threadFuncOverloadMode, 1, 0) == 0) + m_log.DebugFormat("Threadfunc: enable overload mode (Queued {0}, Running {1})", numQueued, numRunning); + } + else if ((threadFuncOverloadMode == 1) && (numRunning <= (m_ThreadPool.MaxThreads * 2) / 3)) + { + if (Interlocked.CompareExchange(ref threadFuncOverloadMode, 0, 1) == 1) + m_log.DebugFormat("Threadfunc: disable overload mode (Queued {0}, Running {1})", numQueued, numRunning); + } } if (loggingEnabled || (threadFuncOverloadMode == 1)) @@ -2325,6 +2329,13 @@ namespace OpenSim.Framework /// public static void RunThreadNoTimeout(WaitCallback callback, string name, object obj) { + if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest) + { + Culture.SetCurrentCulture(); + callback(obj); + return; + } + Thread t = new Thread(delegate() { try -- cgit v1.1