From 3bb0fe098fc721a4d5059c0505c4d31165451f9f Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Fri, 22 Feb 2008 13:23:45 +0000 Subject: Maintenance thread in charge of loading/unloading of scripts. 1 thread less per region. Total so far: 2 threads less per region Note: Currently causes delay in load/unload of scripts --- .../Common/ScriptEngineBase/MaintenanceThread.cs | 5 +++ .../Common/ScriptEngineBase/ScriptManager.cs | 40 +++++++++++++--------- 2 files changed, 28 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Common') diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs index 14f7c4f..5c9f76d 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs @@ -168,6 +168,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time } } + + // LOAD / UNLOAD SCRIPTS + if (m_ScriptEngine.m_ScriptManager != null) + m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload(); + } } } diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs index 20ff07a..7939219 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs @@ -129,14 +129,14 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase if (PrivateThread) { // Assign one thread per region - scriptLoadUnloadThread = StartScriptLoadUnloadThread(); + //scriptLoadUnloadThread = StartScriptLoadUnloadThread(); } else { // Shared thread - make sure one exist, then assign it to the private if (staticScriptLoadUnloadThread == null) { - staticScriptLoadUnloadThread = StartScriptLoadUnloadThread(); + //staticScriptLoadUnloadThread = StartScriptLoadUnloadThread(); } scriptLoadUnloadThread = staticScriptLoadUnloadThread; } @@ -196,21 +196,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase Thread.Sleep(scriptLoadUnloadThread_IdleSleepms); //if (PleaseShutdown) // return; - if (LUQueue.Count > 0) - { - LUStruct item = LUQueue.Dequeue(); - lock (startStopLock) // Lock so we have only 1 thread working on loading/unloading of scripts - { - if (item.Action == LUType.Unload) - { - _StopScript(item.localID, item.itemID); - } - if (item.Action == LUType.Load) - { - _StartScript(item.localID, item.itemID, item.script); - } - } - } + DoScriptLoadUnload(); } } catch (ThreadAbortException tae) @@ -221,6 +207,26 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase } } + public void DoScriptLoadUnload() + { + if (LUQueue.Count > 0) + { + LUStruct item = LUQueue.Dequeue(); + lock (startStopLock) // Lock so we have only 1 thread working on loading/unloading of scripts + { + if (item.Action == LUType.Unload) + { + _StopScript(item.localID, item.itemID); + } + if (item.Action == LUType.Load) + { + _StartScript(item.localID, item.itemID, item.script); + } + } + } + + } + #endregion #region Helper functions -- cgit v1.1