Fixed unit tests due to changes in the threadpool

0.8.0.3
Oren Hurvitz 2014-03-25 10:04:52 +02:00
parent e131e73652
commit 4289b71141
1 changed files with 19 additions and 8 deletions

View File

@ -2081,15 +2081,19 @@ namespace OpenSim.Framework
try try
{ {
long numRunning = numRunningThreadFuncs; long numRunning = numRunningThreadFuncs;
if ((threadFuncOverloadMode == 0) && (numRunning >= m_ThreadPool.MaxThreads))
if (m_ThreadPool != null)
{ {
if (Interlocked.CompareExchange(ref threadFuncOverloadMode, 1, 0) == 0) if ((threadFuncOverloadMode == 0) && (numRunning >= m_ThreadPool.MaxThreads))
m_log.DebugFormat("Threadfunc: enable overload mode (Queued {0}, Running {1})", numQueued, numRunning); {
} if (Interlocked.CompareExchange(ref threadFuncOverloadMode, 1, 0) == 0)
else if ((threadFuncOverloadMode == 1) && (numRunning <= (m_ThreadPool.MaxThreads*2)/3)) m_log.DebugFormat("Threadfunc: enable overload mode (Queued {0}, Running {1})", numQueued, numRunning);
{ }
if (Interlocked.CompareExchange(ref threadFuncOverloadMode, 0, 1) == 1) else if ((threadFuncOverloadMode == 1) && (numRunning <= (m_ThreadPool.MaxThreads * 2) / 3))
m_log.DebugFormat("Threadfunc: disable overload mode (Queued {0}, Running {1})", numQueued, numRunning); {
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)) if (loggingEnabled || (threadFuncOverloadMode == 1))
@ -2325,6 +2329,13 @@ namespace OpenSim.Framework
/// </summary> /// </summary>
public static void RunThreadNoTimeout(WaitCallback callback, string name, object obj) public static void RunThreadNoTimeout(WaitCallback callback, string name, object obj)
{ {
if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest)
{
Culture.SetCurrentCulture();
callback(obj);
return;
}
Thread t = new Thread(delegate() Thread t = new Thread(delegate()
{ {
try try