From fec70166658bd2e020ee6cdc672a77e35a9c5159 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 23 Mar 2012 01:46:11 +0000 Subject: [PATCH] Remove unnecessary shutting down check in Scene.Heartbeat(). Add some method doc. Rename HeartbeatThread, shuttingdown to conform to code standards. --- OpenSim/Region/Framework/Scenes/Scene.cs | 37 +++++++++++++----------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8e5dd03e5f..fbbf68080c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -230,8 +230,19 @@ namespace OpenSim.Region.Framework.Scenes /// private int m_LastLogin; - private Thread HeartbeatThread; - private volatile bool shuttingdown; + /// + /// Thread that runs the scene loop. + /// + private Thread m_heartbeatThread; + + /// + /// True if these scene is in the process of shutting down or is shutdown. + /// + public bool ShuttingDown + { + get { return m_shuttingDown; } + } + private volatile bool m_shuttingDown; // private int m_lastUpdate; // private bool m_firstHeartbeat = true; @@ -818,11 +829,6 @@ namespace OpenSim.Region.Framework.Scenes #region Startup / Close Methods - public bool ShuttingDown - { - get { return shuttingdown; } - } - /// /// The scene graph for this scene /// @@ -1139,8 +1145,7 @@ namespace OpenSim.Region.Framework.Scenes ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); // Stop updating the scene objects and agents. - //m_heartbeatTimer.Close(); - shuttingdown = true; + m_shuttingDown = true; m_log.Debug("[SCENE]: Persisting changed objects"); EventManager.TriggerSceneShuttingDown(this); @@ -1173,14 +1178,14 @@ namespace OpenSim.Region.Framework.Scenes //m_heartbeatTimer.Enabled = true; //m_heartbeatTimer.Interval = (int)(m_timespan * 1000); //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); - if (HeartbeatThread != null) + if (m_heartbeatThread != null) { - HeartbeatThread.Abort(); - HeartbeatThread = null; + m_heartbeatThread.Abort(); + m_heartbeatThread = null; } // m_lastUpdate = Util.EnvironmentTickCount(); - HeartbeatThread + m_heartbeatThread = Watchdog.StartThread( Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); } @@ -1227,9 +1232,7 @@ namespace OpenSim.Region.Framework.Scenes // alarms for scenes with many objects. Update(1); Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true; - - while (!shuttingdown) - Update(-1); + Update(-1); // m_lastUpdate = Util.EnvironmentTickCount(); // m_firstHeartbeat = false; @@ -1257,7 +1260,7 @@ namespace OpenSim.Region.Framework.Scenes List coarseLocations; List avatarUUIDs; - while (!shuttingdown && (endFrame == null || Frame < endFrame)) + while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) { maintc = Util.EnvironmentTickCount(); ++Frame;