diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs index 70db724..730b63e 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs | |||
@@ -69,21 +69,25 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
69 | /// <summary> | 69 | /// <summary> |
70 | /// List of threads processing event queue | 70 | /// List of threads processing event queue |
71 | /// </summary> | 71 | /// </summary> |
72 | private List<EventQueueThreadClass> eventQueueThreads = new List<EventQueueThreadClass>(); | 72 | private List<EventQueueThreadClass> eventQueueThreads;// = new List<EventQueueThreadClass>(); |
73 | private object eventQueueThreadsLock = new object(); | 73 | private object eventQueueThreadsLock;// = new object(); |
74 | |||
75 | private static List<EventQueueThreadClass> staticEventQueueThreads;// = new List<EventQueueThreadClass>(); | ||
76 | private static object staticEventQueueThreadsLock;// = new object(); | ||
74 | 77 | ||
75 | public object queueLock = new object(); // Mutex lock object | 78 | public object queueLock = new object(); // Mutex lock object |
76 | 79 | ||
77 | /// <summary> | 80 | /// <summary> |
78 | /// How many threads to process queue with | 81 | /// How many threads to process queue with |
79 | /// </summary> | 82 | /// </summary> |
80 | private int numberOfThreads = 2; | 83 | private int numberOfThreads; |
81 | 84 | ||
82 | /// <summary> | 85 | /// <summary> |
83 | /// Maximum time one function can use for execution before we perform a thread kill | 86 | /// Maximum time one function can use for execution before we perform a thread kill |
84 | /// </summary> | 87 | /// </summary> |
85 | private int maxFunctionExecutionTimems = 50; | 88 | private int maxFunctionExecutionTimems; |
86 | private bool EnforceMaxExecutionTime = true; | 89 | private bool EnforceMaxExecutionTime; |
90 | |||
87 | 91 | ||
88 | /// <summary> | 92 | /// <summary> |
89 | /// Queue containing events waiting to be executed | 93 | /// Queue containing events waiting to be executed |
@@ -138,6 +142,36 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
138 | { | 142 | { |
139 | m_ScriptEngine = _ScriptEngine; | 143 | m_ScriptEngine = _ScriptEngine; |
140 | 144 | ||
145 | |||
146 | // Create thread pool list and lock object | ||
147 | // Determine from config if threads should be dedicated to regions or shared | ||
148 | if (m_ScriptEngine.ScriptConfigSource.GetBoolean("PrivateRegionThreads", false)) | ||
149 | { | ||
150 | // PRIVATE THREAD POOL PER REGION | ||
151 | eventQueueThreads = new List<EventQueueThreadClass>(); | ||
152 | eventQueueThreadsLock = new object(); | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | // SHARED THREAD POOL | ||
157 | // Crate the objects in statics | ||
158 | if (staticEventQueueThreads == null) | ||
159 | staticEventQueueThreads = new List<EventQueueThreadClass>(); | ||
160 | if (staticEventQueueThreadsLock == null) | ||
161 | staticEventQueueThreadsLock = new object(); | ||
162 | |||
163 | // Create local reference to them | ||
164 | eventQueueThreads = staticEventQueueThreads; | ||
165 | eventQueueThreadsLock = staticEventQueueThreadsLock; | ||
166 | } | ||
167 | |||
168 | numberOfThreads = m_ScriptEngine.ScriptConfigSource.GetInt("NumberOfScriptThreads", 2); | ||
169 | |||
170 | maxFunctionExecutionTimems = m_ScriptEngine.ScriptConfigSource.GetInt("MaxEventExecutionTimeMs", 5000); | ||
171 | EnforceMaxExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("EnforceMaxEventExecutionTime", false); | ||
172 | |||
173 | |||
174 | |||
141 | // Start function max exec time enforcement thread | 175 | // Start function max exec time enforcement thread |
142 | if (EnforceMaxExecutionTime) | 176 | if (EnforceMaxExecutionTime) |
143 | { | 177 | { |
@@ -150,9 +184,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
150 | // | 184 | // |
151 | // Start event queue processing threads (worker threads) | 185 | // Start event queue processing threads (worker threads) |
152 | // | 186 | // |
187 | |||
153 | lock (eventQueueThreadsLock) | 188 | lock (eventQueueThreadsLock) |
154 | { | 189 | { |
155 | for (int ThreadCount = 0; ThreadCount <= numberOfThreads; ThreadCount++) | 190 | for (int ThreadCount = eventQueueThreads.Count; ThreadCount <= numberOfThreads; ThreadCount++) |
156 | { | 191 | { |
157 | StartNewThreadClass(); | 192 | StartNewThreadClass(); |
158 | } | 193 | } |
@@ -315,7 +350,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
315 | } | 350 | } |
316 | } | 351 | } |
317 | 352 | ||
318 | private static void AbortThreadClass(EventQueueThreadClass threadClass) | 353 | private void AbortThreadClass(EventQueueThreadClass threadClass) |
319 | { | 354 | { |
320 | try | 355 | try |
321 | { | 356 | { |
@@ -326,12 +361,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
326 | Console.WriteLine("Could you please report this to Tedd:"); | 361 | Console.WriteLine("Could you please report this to Tedd:"); |
327 | Console.WriteLine("Script thread execution timeout kill ended in exception: " + ex.ToString()); | 362 | Console.WriteLine("Script thread execution timeout kill ended in exception: " + ex.ToString()); |
328 | } | 363 | } |
364 | m_ScriptEngine.Log.Debug("DotNetEngine", "Killed script execution thread, count: " + eventQueueThreads.Count); | ||
329 | } | 365 | } |
330 | 366 | ||
331 | private void StartNewThreadClass() | 367 | private void StartNewThreadClass() |
332 | { | 368 | { |
333 | EventQueueThreadClass eqtc = new EventQueueThreadClass(this); | 369 | EventQueueThreadClass eqtc = new EventQueueThreadClass(this); |
334 | eventQueueThreads.Add(eqtc); | 370 | eventQueueThreads.Add(eqtc); |
371 | m_ScriptEngine.Log.Debug("DotNetEngine", "Started new script execution thread, count: " + eventQueueThreads.Count); | ||
372 | |||
335 | } | 373 | } |
336 | } | 374 | } |
337 | } \ No newline at end of file | 375 | } \ No newline at end of file |