aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs43
1 files changed, 42 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
index 67cf0e2..57caad5 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
@@ -21,10 +21,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
21 21
22 public DateTime LastExecutionStarted; 22 public DateTime LastExecutionStarted;
23 public bool InExecution = false; 23 public bool InExecution = false;
24 public bool KillCurrentScript = false;
24 25
25 private EventQueueManager eventQueueManager; 26 private EventQueueManager eventQueueManager;
26 public Thread EventQueueThread; 27 public Thread EventQueueThread;
27 private static int ThreadCount = 0; 28 private static int ThreadCount = 0;
29 private ThreadPriority MyThreadPriority;
28 30
29 public EventQueueThreadClass(EventQueueManager eqm) 31 public EventQueueThreadClass(EventQueueManager eqm)
30 { 32 {
@@ -43,9 +45,36 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
43 /// </summary> 45 /// </summary>
44 private void Start() 46 private void Start()
45 { 47 {
48 // Later with ScriptServer we might want to ask OS for stuff too, so doing this a bit manually
49 string pri = eventQueueManager.m_ScriptEngine.ScriptConfigSource.GetString("ScriptThreadPriority", "BelowNormal");
50 switch (pri.ToLower())
51 {
52 case "lowest":
53 MyThreadPriority = ThreadPriority.Lowest;
54 break;
55 case "belownormal":
56 MyThreadPriority = ThreadPriority.BelowNormal;
57 break;
58 case "normal":
59 MyThreadPriority = ThreadPriority.Normal;
60 break;
61 case "abovenormal":
62 MyThreadPriority = ThreadPriority.AboveNormal;
63 break;
64 case "highest":
65 MyThreadPriority = ThreadPriority.Highest;
66 break;
67 default:
68 MyThreadPriority = ThreadPriority.BelowNormal; // Default
69 eventQueueManager.m_ScriptEngine.Log.Error("ScriptEngineBase", "Unknown priority type \"" + pri + "\" in config file. Defaulting to \"BelowNormal\".");
70 break;
71 }
72
73
46 EventQueueThread = new Thread(EventQueueThreadLoop); 74 EventQueueThread = new Thread(EventQueueThreadLoop);
47 EventQueueThread.IsBackground = true; 75 EventQueueThread.IsBackground = true;
48 EventQueueThread.Priority = ThreadPriority.BelowNormal; 76
77 EventQueueThread.Priority = MyThreadPriority;
49 EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount; 78 EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount;
50 EventQueueThread.Start(); 79 EventQueueThread.Start();
51 80
@@ -134,6 +163,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
134 + ", QIS.functionName: " + QIS.functionName); 163 + ", QIS.functionName: " + QIS.functionName);
135#endif 164#endif
136 LastExecutionStarted = DateTime.Now; 165 LastExecutionStarted = DateTime.Now;
166 KillCurrentScript = false;
137 InExecution = true; 167 InExecution = true;
138 eventQueueManager.m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, 168 eventQueueManager.m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID,
139 QIS.functionName, QIS.llDetectParams, QIS.param); 169 QIS.functionName, QIS.llDetectParams, QIS.param);
@@ -155,6 +185,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
155 // Send normal 185 // Send normal
156 text += e.Message.ToString(); 186 text += e.Message.ToString();
157 } 187 }
188 if (KillCurrentScript)
189 text += "\r\nScript will be deactivated!";
190
158 try 191 try
159 { 192 {
160 if (text.Length > 1500) 193 if (text.Length > 1500)
@@ -174,6 +207,14 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
174 eventQueueManager.m_ScriptEngine.Log.Error("ScriptEngine", 207 eventQueueManager.m_ScriptEngine.Log.Error("ScriptEngine",
175 "Unable to send text in-world:\r\n" + text); 208 "Unable to send text in-world:\r\n" + text);
176 } 209 }
210 finally
211 {
212 // So we are done sending message in-world
213 if (KillCurrentScript)
214 {
215 eventQueueManager.m_ScriptEngine.m_ScriptManager.RemoveScript(QIS.localID, QIS.itemID);
216 }
217 }
177 } 218 }
178 finally 219 finally
179 { 220 {