One more: Async LSL command thread is also shared now.
parent
9b675a6888
commit
f06a6573bb
|
@ -41,28 +41,36 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
/// </summary>
|
||||
public class AsyncLSLCommandManager : iScriptEngineFunctionModule
|
||||
{
|
||||
private Thread cmdHandlerThread;
|
||||
private static Thread cmdHandlerThread;
|
||||
private int cmdHandlerThreadCycleSleepms;
|
||||
|
||||
private ScriptEngine m_ScriptEngine;
|
||||
|
||||
public AsyncLSLCommandManager(ScriptEngine _ScriptEngine)
|
||||
public AsyncLSLCommandManager()
|
||||
{
|
||||
m_ScriptEngine = _ScriptEngine;
|
||||
//m_ScriptEngine = _ScriptEngine;
|
||||
ReadConfig();
|
||||
|
||||
StartThread();
|
||||
}
|
||||
|
||||
private void StartThread()
|
||||
{
|
||||
if (cmdHandlerThread == null)
|
||||
{
|
||||
// Start the thread that will be doing the work
|
||||
cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
|
||||
cmdHandlerThread.Name = "CmdHandlerThread";
|
||||
cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread";
|
||||
cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
|
||||
cmdHandlerThread.IsBackground = true;
|
||||
cmdHandlerThread.Start();
|
||||
OpenSim.Framework.ThreadTracker.Add(cmdHandlerThread);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadConfig()
|
||||
{
|
||||
cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 50);
|
||||
cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 100);
|
||||
}
|
||||
|
||||
~AsyncLSLCommandManager()
|
||||
|
@ -88,29 +96,46 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
{
|
||||
while (true)
|
||||
{
|
||||
// Check timers
|
||||
CheckTimerEvents();
|
||||
Thread.Sleep(25);
|
||||
// Check HttpRequests
|
||||
CheckHttpRequests();
|
||||
Thread.Sleep(25);
|
||||
// Check XMLRPCRequests
|
||||
CheckXMLRPCRequests();
|
||||
Thread.Sleep(25);
|
||||
// Check Listeners
|
||||
CheckListeners();
|
||||
Thread.Sleep(25);
|
||||
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
||||
lock (ScriptEngine.ScriptEngines)
|
||||
{
|
||||
foreach (ScriptEngine se in ScriptEngine.ScriptEngines)
|
||||
{
|
||||
m_ScriptEngine = se;
|
||||
m_ScriptEngine.m_ASYNCLSLCommandManager.DoOneCmdHandlerPass();
|
||||
}
|
||||
}
|
||||
// Sleep before next cycle
|
||||
//Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void DoOneCmdHandlerPass()
|
||||
{
|
||||
// Check timers
|
||||
CheckTimerEvents();
|
||||
// Check HttpRequests
|
||||
CheckHttpRequests();
|
||||
// Check XMLRPCRequests
|
||||
CheckXMLRPCRequests();
|
||||
// Check Listeners
|
||||
CheckListeners();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a specific script (and all its pending commands)
|
||||
/// </summary>
|
||||
/// <param name="m_localID"></param>
|
||||
/// <param name="m_itemID"></param>
|
||||
/// <param name="localID"></param>
|
||||
/// <param name="itemID"></param>
|
||||
public void RemoveScript(uint localID, LLUUID itemID)
|
||||
{
|
||||
// Remove a specific script
|
||||
|
|
|
@ -73,6 +73,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
|
||||
public void ReadConfig()
|
||||
{
|
||||
//lock (ScriptEngine.ScriptEngines)
|
||||
//{
|
||||
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
||||
{
|
||||
ScriptEngineName = m_ScriptEngine.ScriptEngineName;
|
||||
|
@ -104,7 +106,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
||||
// Now set that priority
|
||||
if (EventQueueThread != null)
|
||||
if (EventQueueThread.IsAlive)
|
||||
|
@ -187,6 +189,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
|
||||
public void DoProcessQueue()
|
||||
{
|
||||
//lock (ScriptEngine.ScriptEngines)
|
||||
//{
|
||||
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
||||
{
|
||||
lastScriptEngine = m_ScriptEngine;
|
||||
|
@ -318,7 +322,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
//else
|
||||
//{
|
||||
// T oconsole
|
||||
m_ScriptEngine.m_EventQueueManager.m_ScriptEngine.Log.Error("[" + ScriptEngineName + "]: " +
|
||||
m_ScriptEngine.m_EventQueueManager.m_ScriptEngine.Log.Error("[" + ScriptEngineName +
|
||||
"]: " +
|
||||
"Unable to send text in-world:\r\n" +
|
||||
text);
|
||||
}
|
||||
|
@ -340,6 +345,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
|
|
|
@ -63,15 +63,20 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
public void ReadConfig()
|
||||
{
|
||||
// Bad hack, but we need a m_ScriptEngine :)
|
||||
lock (ScriptEngine.ScriptEngines)
|
||||
{
|
||||
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
|
||||
{
|
||||
MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
|
||||
MaintenanceLoopTicks_ScriptLoadUnload = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
|
||||
MaintenanceLoopTicks_Other = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
|
||||
MaintenanceLoopTicks_ScriptLoadUnload =
|
||||
m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
|
||||
MaintenanceLoopTicks_Other =
|
||||
m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region " Maintenance thread "
|
||||
/// <summary>
|
||||
|
@ -159,7 +164,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
MaintenanceLoopTicks_Other_Count++;
|
||||
|
||||
|
||||
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
||||
lock (ScriptEngine.ScriptEngines)
|
||||
{
|
||||
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
|
||||
{
|
||||
lastScriptEngine = m_ScriptEngine;
|
||||
// Re-reading config every x seconds
|
||||
|
@ -168,7 +175,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
MaintenanceLoopTicks_Other_ResetCount = true;
|
||||
if (m_ScriptEngine.RefreshConfigFilens > 0)
|
||||
{
|
||||
|
||||
// Check if its time to re-read config
|
||||
if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
|
||||
m_ScriptEngine.RefreshConfigFilens)
|
||||
|
@ -197,7 +203,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
|
||||
{
|
||||
|
@ -209,6 +214,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (lastScriptEngine != null)
|
||||
|
|
|
@ -84,8 +84,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
public ScriptEngine()
|
||||
{
|
||||
Common.mySE = this; // For logging, just need any instance, doesn't matter
|
||||
lock (ScriptEngines)
|
||||
{
|
||||
ScriptEngines.Add(this); // Keep a list of ScriptEngines for shared threads to process all instances
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeEngine(Scene Sceneworld, IConfigSource config, bool HookUpToServer, ScriptManager newScriptManager)
|
||||
{
|
||||
|
@ -107,7 +110,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
newScriptManager.Start();
|
||||
m_ScriptManager = newScriptManager;
|
||||
m_AppDomainManager = new AppDomainManager(this);
|
||||
m_ASYNCLSLCommandManager = new AsyncLSLCommandManager(this);
|
||||
m_ASYNCLSLCommandManager = new AsyncLSLCommandManager();
|
||||
if (m_MaintenanceThread == null)
|
||||
m_MaintenanceThread = new MaintenanceThread();
|
||||
|
||||
|
@ -121,8 +124,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
public void Shutdown()
|
||||
{
|
||||
// We are shutting down
|
||||
lock (ScriptEngines)
|
||||
{
|
||||
ScriptEngines.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ScriptEngine.EventManager()
|
||||
{
|
||||
|
@ -136,13 +142,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
#endif
|
||||
RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 30);
|
||||
|
||||
// Reload from disk? No!
|
||||
//ConfigSource.Reload();
|
||||
//if (File.Exists(OpenSim.Application.iniFilePath))
|
||||
//{
|
||||
// //ConfigSource.Merge(new IniConfigSource(OpenSim.Application.iniFilePath));
|
||||
//}
|
||||
|
||||
|
||||
// Create a new object (probably not necessary?)
|
||||
// ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
|
||||
|
@ -179,15 +178,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
|||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// If set to true then threads and stuff should try to make a graceful exit
|
||||
/// </summary>
|
||||
//public bool PleaseShutdown
|
||||
//{
|
||||
// get { return _PleaseShutdown; }
|
||||
// set { _PleaseShutdown = value; }
|
||||
//}
|
||||
//private bool _PleaseShutdown = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,12 +210,6 @@ SleepTimeIfNoScriptExecutionMs=50
|
|||
; Each AppDomain has some memory overhead. But leaving dead scripts in memory also has memory overhead.
|
||||
ScriptsPerAppDomain=1
|
||||
|
||||
; Script loading / unloading sleep
|
||||
; How long load/unload thread should sleep if there is nothing to do
|
||||
; Higher value makes it respond slower when scripts are added/removed from prims
|
||||
; But once active it will process all in queue before sleeping again
|
||||
|
||||
|
||||
; MaintenanceLoop
|
||||
; How often to run maintenance loop
|
||||
; Maintenance loop is doing: script compile/load, script unload, reload config, adjust running config and enforce max execution time
|
||||
|
@ -224,6 +218,10 @@ MaintenanceLoopms=50
|
|||
; How many maintenanceloops between each of these.
|
||||
; (if 2 then function will be executed every MaintenanceLoopms*2 ms)
|
||||
; Script loading/unloading
|
||||
|
||||
; How long load/unload thread should sleep if there is nothing to do
|
||||
; Higher value makes it respond slower when scripts are added/removed from prims
|
||||
; But once active it will process all in queue before sleeping again
|
||||
MaintenanceLoopTicks_ScriptLoadUnload=1
|
||||
|
||||
; Other tasks
|
||||
|
|
Loading…
Reference in New Issue