mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
refactor: Move methods to start a monitored thread, start work in its own thread and run work in the jobengine from Watchdog to a WorkManager class.
This is to achieve a clean separation of concerns - the watchdog is an inappropriate place for work management. Also adds a WorkManager.RunInThreadPool() class which feeds through to Util.FireAndForget. Also switches around the name and obj arguments to the new RunInThread() and RunJob() methods so that the callback obj comes after the callback as seen in the SDK and elsewhere
This commit is contained in:
@@ -1428,7 +1428,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
m_heartbeatThread
|
||||
= Watchdog.StartThread(
|
||||
= WorkManager.StartThread(
|
||||
Heartbeat, string.Format("Heartbeat-({0})", RegionInfo.RegionName.Replace(" ", "_")), ThreadPriority.Normal, false, false);
|
||||
|
||||
StartScripts();
|
||||
@@ -1469,7 +1469,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// alarms for scenes with many objects.
|
||||
Update(1);
|
||||
|
||||
Watchdog.StartThread(
|
||||
WorkManager.StartThread(
|
||||
Maintenance, string.Format("Maintenance ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, true);
|
||||
|
||||
Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true;
|
||||
@@ -1568,10 +1568,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
tmpMS = Util.EnvironmentTickCount();
|
||||
m_cleaningTemps = true;
|
||||
|
||||
Watchdog.RunInThread(
|
||||
WorkManager.RunInThread(
|
||||
delegate { CleanTempObjects(); m_cleaningTemps = false; },
|
||||
string.Format("CleanTempObjects ({0})", Name),
|
||||
null);
|
||||
null,
|
||||
string.Format("CleanTempObjects ({0})", Name));
|
||||
|
||||
tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
|
||||
}
|
||||
@@ -1843,7 +1843,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (!m_backingup)
|
||||
{
|
||||
m_backingup = true;
|
||||
Watchdog.RunInThread(o => Backup(false), string.Format("BackupWaitCallback ({0})", Name), null);
|
||||
WorkManager.RunInThread(o => Backup(false), null, string.Format("BackupWaitCallback ({0})", Name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1228,11 +1228,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// viewers without (e.g. v1 viewers) will not, so we still need to make this call.
|
||||
if (Scene.AttachmentsModule != null)
|
||||
{
|
||||
Watchdog.RunJob(
|
||||
WorkManager.RunJob(
|
||||
"RezAttachments",
|
||||
o => Scene.AttachmentsModule.RezAttachments(this),
|
||||
string.Format("Rez attachments for {0} in {1}", Name, Scene.Name),
|
||||
null);
|
||||
null,
|
||||
string.Format("Rez attachments for {0} in {1}", Name, Scene.Name));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1254,11 +1254,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if (attachments.Count > 0)
|
||||
{
|
||||
Watchdog.RunJob(
|
||||
WorkManager.RunJob(
|
||||
"StartAttachmentScripts",
|
||||
o => RestartAttachmentScripts(attachments),
|
||||
string.Format("Start attachment scripts for {0} in {1}", Name, Scene.Name),
|
||||
null,
|
||||
string.Format("Start attachment scripts for {0} in {1}", Name, Scene.Name),
|
||||
true);
|
||||
}
|
||||
}
|
||||
@@ -1815,11 +1815,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// XXX: If we force an update after activity has completed, then multiple attachments do appear correctly on a destination region
|
||||
// If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work.
|
||||
// This may be due to viewer code or it may be something we're not doing properly simulator side.
|
||||
Watchdog.RunJob(
|
||||
WorkManager.RunJob(
|
||||
"ScheduleAttachmentsForFullUpdate",
|
||||
o => ScheduleAttachmentsForFullUpdate(),
|
||||
string.Format("Schedule attachments for full update for {0} in {1}", Name, Scene.Name),
|
||||
null,
|
||||
string.Format("Schedule attachments for full update for {0} in {1}", Name, Scene.Name),
|
||||
true);
|
||||
|
||||
// m_log.DebugFormat(
|
||||
@@ -3375,7 +3375,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
SentInitialDataToClient = true;
|
||||
|
||||
// Send all scene object to the new client
|
||||
Watchdog.RunJob("SendInitialDataToClient", delegate
|
||||
WorkManager.RunJob("SendInitialDataToClient", delegate
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[SCENE PRESENCE]: Sending initial data to {0} agent {1} in {2}, tp flags {3}",
|
||||
@@ -3393,7 +3393,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (e != null && e is SceneObjectGroup)
|
||||
((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient);
|
||||
}
|
||||
}, string.Format("SendInitialDataToClient ({0} in {1})", Name, Scene.Name),null, false, true);
|
||||
}, null, string.Format("SendInitialDataToClient ({0} in {1})", Name, Scene.Name), false, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -4057,11 +4057,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// We don't need to worry about a race condition as the job to later start the scripts is also
|
||||
// JobEngine scheduled and so will always occur after this task.
|
||||
// XXX: This will not be true if JobEngine ever gets more than one thread.
|
||||
Watchdog.RunJob(
|
||||
WorkManager.RunJob(
|
||||
"CopyAttachments",
|
||||
o => Scene.AttachmentsModule.CopyAttachments(cAgent, this),
|
||||
string.Format("Copy attachments for {0} entering {1}", Name, Scene.Name),
|
||||
null,
|
||||
string.Format("Copy attachments for {0} entering {1}", Name, Scene.Name),
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user