diff options
author | John Hurliman | 2009-10-22 12:33:23 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-22 12:33:23 -0700 |
commit | b2ed348aa2746fbf034b713d006e40366c479d5a (patch) | |
tree | 26c114e88f54e64e1fdf17dcc7de1e54165db2bc /OpenSim/Region/Framework/Scenes | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-b2ed348aa2746fbf034b713d006e40366c479d5a.zip opensim-SC-b2ed348aa2746fbf034b713d006e40366c479d5a.tar.gz opensim-SC-b2ed348aa2746fbf034b713d006e40366c479d5a.tar.bz2 opensim-SC-b2ed348aa2746fbf034b713d006e40366c479d5a.tar.xz |
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
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5005ac9..4b87f92 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -81,8 +81,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
81 | 81 | ||
82 | protected Timer m_restartWaitTimer = new Timer(); | 82 | protected Timer m_restartWaitTimer = new Timer(); |
83 | 83 | ||
84 | protected Thread m_updateEntitiesThread; | ||
85 | |||
86 | public SimStatsReporter StatsReporter; | 84 | public SimStatsReporter StatsReporter; |
87 | 85 | ||
88 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 86 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
@@ -945,11 +943,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
945 | HeartbeatThread = null; | 943 | HeartbeatThread = null; |
946 | } | 944 | } |
947 | m_lastUpdate = Environment.TickCount; | 945 | m_lastUpdate = Environment.TickCount; |
948 | HeartbeatThread = new Thread(new ParameterizedThreadStart(Heartbeat)); | 946 | |
949 | HeartbeatThread.SetApartmentState(ApartmentState.MTA); | 947 | HeartbeatThread = Watchdog.StartThread(Heartbeat, "Heartbeat for region " + RegionInfo.RegionName, ThreadPriority.Normal, false); |
950 | HeartbeatThread.Name = string.Format("Heartbeat for region {0}", RegionInfo.RegionName); | ||
951 | HeartbeatThread.Priority = ThreadPriority.AboveNormal; | ||
952 | HeartbeatThread.Start(); | ||
953 | } | 948 | } |
954 | 949 | ||
955 | /// <summary> | 950 | /// <summary> |
@@ -976,12 +971,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
976 | /// <summary> | 971 | /// <summary> |
977 | /// Performs per-frame updates regularly | 972 | /// Performs per-frame updates regularly |
978 | /// </summary> | 973 | /// </summary> |
979 | /// <param name="sender"></param> | 974 | private void Heartbeat() |
980 | /// <param name="e"></param> | ||
981 | private void Heartbeat(object sender) | ||
982 | { | 975 | { |
983 | if (!Monitor.TryEnter(m_heartbeatLock)) | 976 | if (!Monitor.TryEnter(m_heartbeatLock)) |
977 | { | ||
978 | Watchdog.RemoveThread(); | ||
984 | return; | 979 | return; |
980 | } | ||
985 | 981 | ||
986 | try | 982 | try |
987 | { | 983 | { |
@@ -998,6 +994,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
998 | Monitor.Pulse(m_heartbeatLock); | 994 | Monitor.Pulse(m_heartbeatLock); |
999 | Monitor.Exit(m_heartbeatLock); | 995 | Monitor.Exit(m_heartbeatLock); |
1000 | } | 996 | } |
997 | |||
998 | Watchdog.RemoveThread(); | ||
1001 | } | 999 | } |
1002 | 1000 | ||
1003 | /// <summary> | 1001 | /// <summary> |
@@ -1146,6 +1144,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1146 | 1144 | ||
1147 | if ((maintc < (m_timespan * 1000)) && maintc > 0) | 1145 | if ((maintc < (m_timespan * 1000)) && maintc > 0) |
1148 | Thread.Sleep(maintc); | 1146 | Thread.Sleep(maintc); |
1147 | |||
1148 | Watchdog.UpdateThread(); | ||
1149 | } | 1149 | } |
1150 | } | 1150 | } |
1151 | 1151 | ||