From b2ed348aa2746fbf034b713d006e40366c479d5a Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 22 Oct 2009 12:33:23 -0700 Subject: Implemented a Watchdog class. Do not manually create Thread objects anymore, use Watchdog.StartThread(). While your thread is running call Watchdog.UpdateThread(). When it is shutting down call Watchdog.RemoveThread(). Most of the threads in OpenSim have been updated --- OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | 8 +++----- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 13 ++++++------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index fe9c8d9..c9fce91 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -128,7 +128,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (m_repliesRequired == 0) { m_requestState = RequestState.Completed; - PerformAssetsRequestCallback(); + PerformAssetsRequestCallback(null); return; } @@ -246,9 +246,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 - Thread newThread = new Thread(PerformAssetsRequestCallback); - newThread.Name = "OpenSimulator archiving thread post assets receipt"; - newThread.Start(); + Util.FireAndForget(PerformAssetsRequestCallback); } else { @@ -265,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// Perform the callback on the original requester of the assets /// - protected void PerformAssetsRequestCallback() + protected void PerformAssetsRequestCallback(object o) { try { diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 4e40084..a4bcbad 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -74,7 +74,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap private Dictionary m_blacklistedregions = new Dictionary(); private Dictionary m_cachedRegionMapItemsAddress = new Dictionary(); private List m_rootAgents = new List(); - private Thread mapItemReqThread; private volatile bool threadrunning = false; //private int CacheRegionsDistance = 256; @@ -338,13 +337,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap { if (threadrunning) return; threadrunning = true; + m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread"); - mapItemReqThread = new Thread(new ThreadStart(process)); - mapItemReqThread.IsBackground = true; - mapItemReqThread.Name = "MapItemRequestThread"; - mapItemReqThread.Priority = ThreadPriority.BelowNormal; - mapItemReqThread.SetApartmentState(ApartmentState.MTA); - mapItemReqThread.Start(); + + Watchdog.StartThread(process, "MapItemRequestThread", ThreadPriority.BelowNormal, true); } /// @@ -461,6 +457,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap OSDMap response = RequestMapItemsAsync("", st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); RequestMapItemsCompleted(response); } + + Watchdog.UpdateThread(); } } catch (Exception e) @@ -469,6 +467,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } threadrunning = false; + Watchdog.RemoveThread(); } /// -- cgit v1.1