From 0fb0a6816d65df6a97d510fc263a4cb702bb421e Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 5 Jan 2008 20:05:29 +0000 Subject: Only one queue is used for load/unload of scripts. So loading/unloading of scripts are now done in same sequence as they are called. --- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 41 ++++++++++++---------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs') diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index ac378ae..223bb8f 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -63,20 +63,23 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine private Thread scriptLoadUnloadThread; private int scriptLoadUnloadThread_IdleSleepms = 100; - private Queue loadQueue = new Queue(); - private Queue unloadQueue = new Queue(); + private Queue LUQueue = new Queue(); + - private struct LoadStruct + // Load/Unload structure + private struct LUStruct { public uint localID; public LLUUID itemID; public string script; + public LUType Action; } - private struct UnloadStruct + private enum LUType { - public uint localID; - public LLUUID itemID; + Unknown = 0, + Load = 1, + Unload = 2 } // Object> @@ -136,17 +139,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { while (true) { - if (loadQueue.Count == 0 && unloadQueue.Count == 0) + if (LUQueue.Count == 0) Thread.Sleep(scriptLoadUnloadThread_IdleSleepms); - if (unloadQueue.Count > 0) - { - UnloadStruct item = unloadQueue.Dequeue(); - _StopScript(item.localID, item.itemID); - } - if (loadQueue.Count > 0) + if (LUQueue.Count > 0) { - LoadStruct item = loadQueue.Dequeue(); - _StartScript(item.localID, item.itemID, item.script); + LUStruct item = LUQueue.Dequeue(); + if (item.Action == LUType.Unload) + _StopScript(item.localID, item.itemID); + if (item.Action == LUType.Load) + _StartScript(item.localID, item.itemID, item.script); } } } @@ -244,11 +245,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// public void StartScript(uint localID, LLUUID itemID, string Script) { - LoadStruct ls = new LoadStruct(); + LUStruct ls = new LUStruct(); ls.localID = localID; ls.itemID = itemID; ls.script = Script; - loadQueue.Enqueue(ls); + ls.Action = LUType.Load; + LUQueue.Enqueue(ls); } /// @@ -258,10 +260,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// public void StopScript(uint localID, LLUUID itemID) { - UnloadStruct ls = new UnloadStruct(); + LUStruct ls = new LUStruct(); ls.localID = localID; ls.itemID = itemID; - unloadQueue.Enqueue(ls); + ls.Action = LUType.Unload; + LUQueue.Enqueue(ls); } public void ResetScript(uint localID, LLUUID itemID) -- cgit v1.1