diff options
author | Tedd Hansen | 2008-01-05 20:05:29 +0000 |
---|---|---|
committer | Tedd Hansen | 2008-01-05 20:05:29 +0000 |
commit | 0fb0a6816d65df6a97d510fc263a4cb702bb421e (patch) | |
tree | ff011ab7277765380c28b068b60cb8826e8fcb21 /OpenSim/Region/ScriptEngine/DotNetEngine | |
parent | Prim inventory storage phase 2. Add a prim inventory script item to sqlite e... (diff) | |
download | opensim-SC_OLD-0fb0a6816d65df6a97d510fc263a4cb702bb421e.zip opensim-SC_OLD-0fb0a6816d65df6a97d510fc263a4cb702bb421e.tar.gz opensim-SC_OLD-0fb0a6816d65df6a97d510fc263a4cb702bb421e.tar.bz2 opensim-SC_OLD-0fb0a6816d65df6a97d510fc263a4cb702bb421e.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | 41 |
1 files changed, 22 insertions, 19 deletions
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 | |||
63 | 63 | ||
64 | private Thread scriptLoadUnloadThread; | 64 | private Thread scriptLoadUnloadThread; |
65 | private int scriptLoadUnloadThread_IdleSleepms = 100; | 65 | private int scriptLoadUnloadThread_IdleSleepms = 100; |
66 | private Queue<LoadStruct> loadQueue = new Queue<LoadStruct>(); | 66 | private Queue<LUStruct> LUQueue = new Queue<LUStruct>(); |
67 | private Queue<UnloadStruct> unloadQueue = new Queue<UnloadStruct>(); | 67 | |
68 | 68 | ||
69 | private struct LoadStruct | 69 | // Load/Unload structure |
70 | private struct LUStruct | ||
70 | { | 71 | { |
71 | public uint localID; | 72 | public uint localID; |
72 | public LLUUID itemID; | 73 | public LLUUID itemID; |
73 | public string script; | 74 | public string script; |
75 | public LUType Action; | ||
74 | } | 76 | } |
75 | 77 | ||
76 | private struct UnloadStruct | 78 | private enum LUType |
77 | { | 79 | { |
78 | public uint localID; | 80 | Unknown = 0, |
79 | public LLUUID itemID; | 81 | Load = 1, |
82 | Unload = 2 | ||
80 | } | 83 | } |
81 | 84 | ||
82 | // Object<string, Script<string, script>> | 85 | // Object<string, Script<string, script>> |
@@ -136,17 +139,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
136 | { | 139 | { |
137 | while (true) | 140 | while (true) |
138 | { | 141 | { |
139 | if (loadQueue.Count == 0 && unloadQueue.Count == 0) | 142 | if (LUQueue.Count == 0) |
140 | Thread.Sleep(scriptLoadUnloadThread_IdleSleepms); | 143 | Thread.Sleep(scriptLoadUnloadThread_IdleSleepms); |
141 | if (unloadQueue.Count > 0) | 144 | if (LUQueue.Count > 0) |
142 | { | ||
143 | UnloadStruct item = unloadQueue.Dequeue(); | ||
144 | _StopScript(item.localID, item.itemID); | ||
145 | } | ||
146 | if (loadQueue.Count > 0) | ||
147 | { | 145 | { |
148 | LoadStruct item = loadQueue.Dequeue(); | 146 | LUStruct item = LUQueue.Dequeue(); |
149 | _StartScript(item.localID, item.itemID, item.script); | 147 | if (item.Action == LUType.Unload) |
148 | _StopScript(item.localID, item.itemID); | ||
149 | if (item.Action == LUType.Load) | ||
150 | _StartScript(item.localID, item.itemID, item.script); | ||
150 | } | 151 | } |
151 | } | 152 | } |
152 | } | 153 | } |
@@ -244,11 +245,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
244 | /// <param name="localID"></param> | 245 | /// <param name="localID"></param> |
245 | public void StartScript(uint localID, LLUUID itemID, string Script) | 246 | public void StartScript(uint localID, LLUUID itemID, string Script) |
246 | { | 247 | { |
247 | LoadStruct ls = new LoadStruct(); | 248 | LUStruct ls = new LUStruct(); |
248 | ls.localID = localID; | 249 | ls.localID = localID; |
249 | ls.itemID = itemID; | 250 | ls.itemID = itemID; |
250 | ls.script = Script; | 251 | ls.script = Script; |
251 | loadQueue.Enqueue(ls); | 252 | ls.Action = LUType.Load; |
253 | LUQueue.Enqueue(ls); | ||
252 | } | 254 | } |
253 | 255 | ||
254 | /// <summary> | 256 | /// <summary> |
@@ -258,10 +260,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
258 | /// <param name="itemID"></param> | 260 | /// <param name="itemID"></param> |
259 | public void StopScript(uint localID, LLUUID itemID) | 261 | public void StopScript(uint localID, LLUUID itemID) |
260 | { | 262 | { |
261 | UnloadStruct ls = new UnloadStruct(); | 263 | LUStruct ls = new LUStruct(); |
262 | ls.localID = localID; | 264 | ls.localID = localID; |
263 | ls.itemID = itemID; | 265 | ls.itemID = itemID; |
264 | unloadQueue.Enqueue(ls); | 266 | ls.Action = LUType.Unload; |
267 | LUQueue.Enqueue(ls); | ||
265 | } | 268 | } |
266 | 269 | ||
267 | public void ResetScript(uint localID, LLUUID itemID) | 270 | public void ResetScript(uint localID, LLUUID itemID) |