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.
afrisby
Tedd Hansen 2008-01-05 20:05:29 +00:00
parent 52666e64c8
commit 0fb0a6816d
3 changed files with 22 additions and 20 deletions

View File

@ -344,7 +344,6 @@ namespace OpenSim
ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup"); ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup");
MainLog.Instance.Verbose("PLUGINS", "Loading {0} OpenSim application plugins", nodes.Count); MainLog.Instance.Verbose("PLUGINS", "Loading {0} OpenSim application plugins", nodes.Count);
int modcount = 0;
foreach (TypeExtensionNode node in nodes) foreach (TypeExtensionNode node in nodes)
{ {
IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance(); IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance();

View File

@ -63,20 +63,23 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
private Thread scriptLoadUnloadThread; private Thread scriptLoadUnloadThread;
private int scriptLoadUnloadThread_IdleSleepms = 100; private int scriptLoadUnloadThread_IdleSleepms = 100;
private Queue<LoadStruct> loadQueue = new Queue<LoadStruct>(); private Queue<LUStruct> LUQueue = new Queue<LUStruct>();
private Queue<UnloadStruct> unloadQueue = new Queue<UnloadStruct>();
private struct LoadStruct
// Load/Unload structure
private struct LUStruct
{ {
public uint localID; public uint localID;
public LLUUID itemID; public LLUUID itemID;
public string script; public string script;
public LUType Action;
} }
private struct UnloadStruct private enum LUType
{ {
public uint localID; Unknown = 0,
public LLUUID itemID; Load = 1,
Unload = 2
} }
// Object<string, Script<string, script>> // Object<string, Script<string, script>>
@ -136,16 +139,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
while (true) while (true)
{ {
if (loadQueue.Count == 0 && unloadQueue.Count == 0) if (LUQueue.Count == 0)
Thread.Sleep(scriptLoadUnloadThread_IdleSleepms); Thread.Sleep(scriptLoadUnloadThread_IdleSleepms);
if (unloadQueue.Count > 0) if (LUQueue.Count > 0)
{ {
UnloadStruct item = unloadQueue.Dequeue(); LUStruct item = LUQueue.Dequeue();
if (item.Action == LUType.Unload)
_StopScript(item.localID, item.itemID); _StopScript(item.localID, item.itemID);
} if (item.Action == LUType.Load)
if (loadQueue.Count > 0)
{
LoadStruct item = loadQueue.Dequeue();
_StartScript(item.localID, item.itemID, item.script); _StartScript(item.localID, item.itemID, item.script);
} }
} }
@ -244,11 +245,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <param name="localID"></param> /// <param name="localID"></param>
public void StartScript(uint localID, LLUUID itemID, string Script) public void StartScript(uint localID, LLUUID itemID, string Script)
{ {
LoadStruct ls = new LoadStruct(); LUStruct ls = new LUStruct();
ls.localID = localID; ls.localID = localID;
ls.itemID = itemID; ls.itemID = itemID;
ls.script = Script; ls.script = Script;
loadQueue.Enqueue(ls); ls.Action = LUType.Load;
LUQueue.Enqueue(ls);
} }
/// <summary> /// <summary>
@ -258,10 +260,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <param name="itemID"></param> /// <param name="itemID"></param>
public void StopScript(uint localID, LLUUID itemID) public void StopScript(uint localID, LLUUID itemID)
{ {
UnloadStruct ls = new UnloadStruct(); LUStruct ls = new LUStruct();
ls.localID = localID; ls.localID = localID;
ls.itemID = itemID; ls.itemID = itemID;
unloadQueue.Enqueue(ls); ls.Action = LUType.Unload;
LUQueue.Enqueue(ls);
} }
public void ResetScript(uint localID, LLUUID itemID) public void ResetScript(uint localID, LLUUID itemID)

Binary file not shown.