From 89665faeaff2ff62eaaddd0f111be8bcd7ca0297 Mon Sep 17 00:00:00 2001
From: Tedd Hansen
Date: Thu, 21 Feb 2008 11:28:34 +0000
Subject: ScriptEngine changes in locking. Another step in direction of shared
threads.
---
.../Common/ScriptEngineBase/EventQueueManager.cs | 32 ++++++++++------------
.../ScriptEngineBase/EventQueueThreadClass.cs | 14 +++++-----
2 files changed, 22 insertions(+), 24 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
index 267cf52..eaffe3f 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
@@ -60,24 +60,22 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
// Notes:
// * Current execution load balancing is optimized for 1 thread, and can cause unfair execute balancing between scripts.
// Not noticeable unless server is under high load.
- // * This class contains the number of threads used for script executions. Since we are not microthreading scripts yet,
- // increase number of threads to allow more concurrent script executions in OpenSim.
//
public ScriptEngine m_ScriptEngine;
///
/// List of threads (classes) processing event queue
+ /// Note that this may or may not be a reference to a static object depending on PrivateRegionThreads config setting.
///
internal List eventQueueThreads; // Thread pool that we work on
///
/// Locking access to eventQueueThreads AND staticGlobalEventQueueThreads.
- /// Note that this may or may not be a reference to a static object depending on PrivateRegionThreads config setting.
///
- private object eventQueueThreadsLock = new object();
+// private object eventQueueThreadsLock = new object();
// Static objects for referencing the objects above if we don't have private threads:
internal static List staticEventQueueThreads; // A static reference used if we don't use private threads
- internal static object staticEventQueueThreadsLock; // Statick lock object reference for same reason
+// internal static object staticEventQueueThreadsLock; // Statick lock object reference for same reason
///
/// Global static list of all threads (classes) processing event queue -- used by max enforcment thread
@@ -91,7 +89,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public object ThreadsToExitLock = new object();
- public object queueLock = new object(); // Mutex lock object
+ //public object queueLock = new object(); // Mutex lock object
///
/// How many threads to process queue with
@@ -183,7 +181,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
{
// PRIVATE THREAD POOL PER REGION
eventQueueThreads = new List();
- eventQueueThreadsLock = new object();
+ // eventQueueThreadsLock = new object();
}
else
{
@@ -191,12 +189,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
// Crate the static objects
if (staticEventQueueThreads == null)
staticEventQueueThreads = new List();
- if (staticEventQueueThreadsLock == null)
- staticEventQueueThreadsLock = new object();
+ // if (staticEventQueueThreadsLock == null)
+ // staticEventQueueThreadsLock = new object();
// Now reference our locals to them
eventQueueThreads = staticEventQueueThreads;
- eventQueueThreadsLock = staticEventQueueThreadsLock;
+ //eventQueueThreadsLock = staticEventQueueThreadsLock;
}
ReadConfig();
@@ -213,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
EventExecutionMaxQueueSize = m_ScriptEngine.ScriptConfigSource.GetInt("EventExecutionMaxQueueSize", 300);
// Now refresh config in all threads
- lock (eventQueueThreadsLock)
+ lock (eventQueueThreads)
{
foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
{
@@ -232,10 +230,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
private void Stop()
{
- if (eventQueueThreadsLock != null && eventQueueThreads != null)
+ if (eventQueueThreads != null && eventQueueThreads != null)
{
// Kill worker threads
- lock (eventQueueThreadsLock)
+ lock (eventQueueThreads)
{
foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
{
@@ -247,7 +245,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
}
// Remove all entries from our event queue
- lock (queueLock)
+ lock (eventQueue)
{
eventQueue.Clear();
}
@@ -361,7 +359,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// Array of parameters to match event mask
public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
{
- lock (queueLock)
+ lock (eventQueue)
{
if (eventQueue.Count >= EventExecutionMaxQueueSize)
{
@@ -396,7 +394,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
if (eventQueueThreads.Count == numberOfThreads)
return;
- lock (eventQueueThreadsLock)
+ lock (eventQueueThreads)
{
int diff = numberOfThreads - eventQueueThreads.Count;
// Positive number: Start
@@ -426,7 +424,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public void CheckScriptMaxExecTime()
{
// Iterate through all ScriptThreadClasses and check how long their current function has been executing
- lock (eventQueueThreadsLock)
+ lock (eventQueueThreads)
{
foreach (EventQueueThreadClass EventQueueThread in staticGlobalEventQueueThreads)
{
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
index 6f96654..cf66e7a 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
@@ -200,7 +200,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
//myScriptEngine.Log.Info("[" + ScriptEngineName + "]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
- lock (eventQueueManager.queueLock)
+ lock (eventQueueManager.eventQueue)
{
GotItem = false;
for (int qc = 0; qc < eventQueueManager.eventQueue.Count; qc++)
@@ -230,12 +230,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
{
///cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined
#if DEBUG
- eventQueueManager.m_ScriptEngine.Log.Debug("[" + ScriptEngineName + "]: " +
- "Executing event:\r\n"
- + "QIS.localID: " + QIS.localID
- + ", QIS.itemID: " + QIS.itemID
- + ", QIS.functionName: " +
- QIS.functionName);
+ //eventQueueManager.m_ScriptEngine.Log.Debug("[" + ScriptEngineName + "]: " +
+ // "Executing event:\r\n"
+ // + "QIS.localID: " + QIS.localID
+ // + ", QIS.itemID: " + QIS.itemID
+ // + ", QIS.functionName: " +
+ // QIS.functionName);
#endif
LastExecutionStarted = DateTime.Now.Ticks;
KillCurrentScript = false;
--
cgit v1.1