aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
diff options
context:
space:
mode:
authorTedd Hansen2008-02-01 23:36:36 +0000
committerTedd Hansen2008-02-01 23:36:36 +0000
commitd02a90823f2873f1b4de63062e3909d03a5a91fa (patch)
treecb0d8f79fd36bec98bbac39c1185ee40c75e7c6d /OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
parentSCRIPT SUPPORT IS STILL BROKEN. (diff)
downloadopensim-SC_OLD-d02a90823f2873f1b4de63062e3909d03a5a91fa.zip
opensim-SC_OLD-d02a90823f2873f1b4de63062e3909d03a5a91fa.tar.gz
opensim-SC_OLD-d02a90823f2873f1b4de63062e3909d03a5a91fa.tar.bz2
opensim-SC_OLD-d02a90823f2873f1b4de63062e3909d03a5a91fa.tar.xz
SCRIPTING STILL BROKEN
Added comments and regions, restructured code Changed a lot of AppDomain junk from console from using Console.Write to Log.Verbose and set it to #if DEBUG All modules should now refresh their configuration runtime Made all logging in ScriptEngine.Common get script name from actual engine Renamed LSLLongCmdHandler to AsyncLSLCommandManager Added auto-recover with 5 sec throttle for new MaintenanceThread
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs42
1 files changed, 33 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
index 04c084a..3ba4618 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
42 /// Events are queued and executed in separate thread 42 /// Events are queued and executed in separate thread
43 /// </summary> 43 /// </summary>
44 [Serializable] 44 [Serializable]
45 public class EventQueueManager 45 public class EventQueueManager : iScriptEngineFunctionModule
46 { 46 {
47 47
48 // 48 //
@@ -197,13 +197,22 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
197 197
198 } 198 }
199 199
200 private void ReadConfig() 200 public void ReadConfig()
201 { 201 {
202 // Refresh config
202 numberOfThreads = m_ScriptEngine.ScriptConfigSource.GetInt("NumberOfScriptThreads", 2); 203 numberOfThreads = m_ScriptEngine.ScriptConfigSource.GetInt("NumberOfScriptThreads", 2);
203 maxFunctionExecutionTimems = m_ScriptEngine.ScriptConfigSource.GetInt("MaxEventExecutionTimeMs", 5000); 204 maxFunctionExecutionTimems = m_ScriptEngine.ScriptConfigSource.GetInt("MaxEventExecutionTimeMs", 5000);
204 EnforceMaxExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("EnforceMaxEventExecutionTime", false); 205 EnforceMaxExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("EnforceMaxEventExecutionTime", false);
205 KillScriptOnMaxFunctionExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("DeactivateScriptOnTimeout", false); 206 KillScriptOnMaxFunctionExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("DeactivateScriptOnTimeout", false);
206 207
208 // Now refresh config in all threads
209 lock (eventQueueThreadsLock)
210 {
211 foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
212 {
213 EventQueueThread.ReadConfig();
214 }
215 }
207 } 216 }
208 217
209 #endregion 218 #endregion
@@ -222,7 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
222 { 231 {
223 foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads) 232 foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
224 { 233 {
225 EventQueueThread.Shutdown(); 234 AbortThreadClass(EventQueueThread);
226 } 235 }
227 eventQueueThreads.Clear(); 236 eventQueueThreads.Clear();
228 staticGlobalEventQueueThreads.Clear(); 237 staticGlobalEventQueueThreads.Clear();
@@ -243,7 +252,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
243 EventQueueThreadClass eqtc = new EventQueueThreadClass(this); 252 EventQueueThreadClass eqtc = new EventQueueThreadClass(this);
244 eventQueueThreads.Add(eqtc); 253 eventQueueThreads.Add(eqtc);
245 staticGlobalEventQueueThreads.Add(eqtc); 254 staticGlobalEventQueueThreads.Add(eqtc);
246 m_ScriptEngine.Log.Debug("DotNetEngine", "Started new script execution thread. Current thread count: " + eventQueueThreads.Count); 255 m_ScriptEngine.Log.Debug(m_ScriptEngine.ScriptEngineName, "Started new script execution thread. Current thread count: " + eventQueueThreads.Count);
247 256
248 } 257 }
249 private void AbortThreadClass(EventQueueThreadClass threadClass) 258 private void AbortThreadClass(EventQueueThreadClass threadClass)
@@ -252,16 +261,17 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
252 eventQueueThreads.Remove(threadClass); 261 eventQueueThreads.Remove(threadClass);
253 if (staticGlobalEventQueueThreads.Contains(threadClass)) 262 if (staticGlobalEventQueueThreads.Contains(threadClass))
254 staticGlobalEventQueueThreads.Remove(threadClass); 263 staticGlobalEventQueueThreads.Remove(threadClass);
264
255 try 265 try
256 { 266 {
257 threadClass.Shutdown(); 267 threadClass.Stop();
258 } 268 }
259 catch (Exception ex) 269 catch (Exception ex)
260 { 270 {
261 m_ScriptEngine.Log.Error("EventQueueManager", "If you see this, could you please report it to Tedd:"); 271 m_ScriptEngine.Log.Error(m_ScriptEngine.ScriptEngineName + ":EventQueueManager", "If you see this, could you please report it to Tedd:");
262 m_ScriptEngine.Log.Error("EventQueueManager", "Script thread execution timeout kill ended in exception: " + ex.ToString()); 272 m_ScriptEngine.Log.Error(m_ScriptEngine.ScriptEngineName + ":EventQueueManager", "Script thread execution timeout kill ended in exception: " + ex.ToString());
263 } 273 }
264 m_ScriptEngine.Log.Debug("DotNetEngine", "Killed script execution thread. Remaining thread count: " + eventQueueThreads.Count); 274 m_ScriptEngine.Log.Debug(m_ScriptEngine.ScriptEngineName, "Killed script execution thread. Remaining thread count: " + eventQueueThreads.Count);
265 } 275 }
266 #endregion 276 #endregion
267 277
@@ -313,7 +323,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
313 public void AddToObjectQueue(uint localID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param) 323 public void AddToObjectQueue(uint localID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
314 { 324 {
315 // Determine all scripts in Object and add to their queue 325 // Determine all scripts in Object and add to their queue
316 //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName); 326 //myScriptEngine.m_logger.Verbose(ScriptEngineName, "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
317 327
318 328
319 // Do we have any scripts in this object at all? If not, return 329 // Do we have any scripts in this object at all? If not, return
@@ -367,6 +377,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
367 /// </summary> 377 /// </summary>
368 public void AdjustNumberOfScriptThreads() 378 public void AdjustNumberOfScriptThreads()
369 { 379 {
380 // Is there anything here for us to do?
381 if (eventQueueThreads.Count == numberOfThreads)
382 return;
383
370 lock (eventQueueThreadsLock) 384 lock (eventQueueThreadsLock)
371 { 385 {
372 int diff = numberOfThreads - eventQueueThreads.Count; 386 int diff = numberOfThreads - eventQueueThreads.Count;
@@ -424,5 +438,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
424 } 438 }
425 } 439 }
426 #endregion 440 #endregion
441 /// <summary>
442 /// If set to true then threads and stuff should try to make a graceful exit
443 /// </summary>
444 public bool PleaseShutdown
445 {
446 get { return _PleaseShutdown; }
447 set { _PleaseShutdown = value; }
448 }
449 private bool _PleaseShutdown = false;
450
427 } 451 }
428} \ No newline at end of file 452} \ No newline at end of file