mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +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:
@@ -964,11 +964,11 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
case "assets":
|
||||
con.Output("Ensuring assets are cached for all scenes.");
|
||||
|
||||
Watchdog.RunInThread(delegate
|
||||
WorkManager.RunInThread(delegate
|
||||
{
|
||||
int assetReferenceTotal = TouchAllSceneAssets(true);
|
||||
con.OutputFormat("Completed check with {0} assets.", assetReferenceTotal);
|
||||
}, "TouchAllSceneAssets", null);
|
||||
}, null, "TouchAllSceneAssets");
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
m_scene.UserAccountService, m_scene.RegionInfo.ScopeID,
|
||||
options, ReceivedAllAssets);
|
||||
|
||||
Watchdog.RunInThread(o => ar.Execute(), string.Format("AssetsRequest ({0})", m_scene.Name), null);
|
||||
WorkManager.RunInThread(o => ar.Execute(), null, string.Format("AssetsRequest ({0})", m_scene.Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
|
||||
StatsManager.RegisterStat(m_requestsWaitingStat);
|
||||
|
||||
Watchdog.StartThread(
|
||||
WorkManager.StartThread(
|
||||
ProcessRequests,
|
||||
string.Format("HG Incoming Scene Object Engine Thread ({0})", Name),
|
||||
ThreadPriority.Normal,
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace OpenSim.Region.CoreModules.Framework
|
||||
m_timer.Elapsed += ProcessQueue;
|
||||
m_timer.Start();
|
||||
|
||||
//Watchdog.StartThread(
|
||||
//WorkManager.StartThread(
|
||||
// ProcessQueue,
|
||||
// "GridServiceRequestThread",
|
||||
// ThreadPriority.BelowNormal,
|
||||
|
||||
@@ -658,7 +658,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
|
||||
public void Process()
|
||||
{
|
||||
_finished = false;
|
||||
Watchdog.StartThread(SendRequest, "HttpRequestThread", ThreadPriority.BelowNormal, true, false);
|
||||
WorkManager.StartThread(SendRequest, "HttpRequestThread", ThreadPriority.BelowNormal, true, false);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -184,12 +184,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||
// Protect ourselves against the caller subsequently modifying the items list
|
||||
List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
|
||||
|
||||
Watchdog.RunInThread(delegate
|
||||
WorkManager.RunInThread(delegate
|
||||
{
|
||||
foreach (InventoryItemBase item in items)
|
||||
if (!string.IsNullOrEmpty(item.CreatorData))
|
||||
UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
|
||||
}, string.Format("GetFolderContent (user {0}, folder {1})", userID, folderID), null);
|
||||
}, null, string.Format("GetFolderContent (user {0}, folder {1})", userID, folderID));
|
||||
}
|
||||
|
||||
return invCol;
|
||||
|
||||
@@ -372,7 +372,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
// Start the scripts. We delayed this because we want the OAR to finish loading ASAP, so
|
||||
// that users can enter the scene. If we allow the scripts to start in the loop above
|
||||
// then they significantly increase the time until the OAR finishes loading.
|
||||
Watchdog.RunInThread(o =>
|
||||
WorkManager.RunInThread(o =>
|
||||
{
|
||||
Thread.Sleep(15000);
|
||||
m_log.Info("[ARCHIVER]: Starting scripts in scene objects");
|
||||
@@ -387,7 +387,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
sceneContext.SceneObjects.Clear();
|
||||
}
|
||||
}, string.Format("ReadArchiveStartScripts (request {0})", m_requestId), null);
|
||||
}, null, string.Format("ReadArchiveStartScripts (request {0})", m_requestId));
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
m_rootScene.AssetService, m_rootScene.UserAccountService,
|
||||
m_rootScene.RegionInfo.ScopeID, options, ReceivedAllAssets);
|
||||
|
||||
Watchdog.RunInThread(o => ar.Execute(), "Archive Assets Request", null);
|
||||
WorkManager.RunInThread(o => ar.Execute(), null, "Archive Assets Request");
|
||||
|
||||
// CloseArchive() will be called from ReceivedAllAssets()
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
finally
|
||||
{
|
||||
if (timedOut)
|
||||
Watchdog.RunInThread(PerformAssetsRequestCallback, "Archive Assets Request Callback", true);
|
||||
WorkManager.RunInThread(PerformAssetsRequestCallback, true, "Archive Assets Request Callback");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
// We want to stop using the asset cache thread asap
|
||||
// as we now need to do the work of producing the rest of the archive
|
||||
Watchdog.RunInThread(PerformAssetsRequestCallback, "Archive Assets Request Callback", false);
|
||||
WorkManager.RunInThread(PerformAssetsRequestCallback, false, "Archive Assets Request Callback");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -381,7 +381,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
|
||||
// m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread");
|
||||
|
||||
Watchdog.StartThread(
|
||||
WorkManager.StartThread(
|
||||
process,
|
||||
string.Format("MapItemRequestThread ({0})", m_scene.RegionInfo.RegionName),
|
||||
ThreadPriority.BelowNormal,
|
||||
|
||||
Reference in New Issue
Block a user