aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-23 01:02:36 -0700
committerJohn Hurliman2009-10-23 01:02:36 -0700
commit588361e2a2398b963871762c2b5485c6a086cf47 (patch)
tree5be2c6705096817c599075da4e12a0e9b0a4c841 /OpenSim/Region/Framework/Scenes/Scene.cs
parentAdded VS2010 support to Prebuild and created runprebuild2010.bat (diff)
downloadopensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.zip
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.gz
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.bz2
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.xz
Experimental change to use an immutable array for iterating ScenePresences, avoiding locking and copying the list each time it is accessed
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs25
1 files changed, 10 insertions, 15 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4b87f92..d5e3445 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -253,7 +253,7 @@ namespace OpenSim.Region.Framework.Scenes
253 protected int m_fps = 10; 253 protected int m_fps = 10;
254 protected int m_frame = 0; 254 protected int m_frame = 0;
255 protected float m_timespan = 0.089f; 255 protected float m_timespan = 0.089f;
256 protected DateTime m_lastupdate = DateTime.Now; 256 protected DateTime m_lastupdate = DateTime.UtcNow;
257 257
258 private int m_update_physics = 1; 258 private int m_update_physics = 1;
259 private int m_update_entitymovement = 1; 259 private int m_update_entitymovement = 1;
@@ -1014,7 +1014,7 @@ namespace OpenSim.Region.Framework.Scenes
1014//#endif 1014//#endif
1015 maintc = Environment.TickCount; 1015 maintc = Environment.TickCount;
1016 1016
1017 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; 1017 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1018 float physicsFPS = 0; 1018 float physicsFPS = 0;
1019 1019
1020 frameMS = Environment.TickCount; 1020 frameMS = Environment.TickCount;
@@ -1137,7 +1137,7 @@ namespace OpenSim.Region.Framework.Scenes
1137 } 1137 }
1138 m_timedilation = tmpval; 1138 m_timedilation = tmpval;
1139 1139
1140 m_lastupdate = DateTime.Now; 1140 m_lastupdate = DateTime.UtcNow;
1141 } 1141 }
1142 maintc = Environment.TickCount - maintc; 1142 maintc = Environment.TickCount - maintc;
1143 maintc = (int)(m_timespan * 1000) - maintc; 1143 maintc = (int)(m_timespan * 1000) - maintc;
@@ -3496,9 +3496,7 @@ namespace OpenSim.Region.Framework.Scenes
3496 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 3496 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
3497 { 3497 {
3498 ScenePresence presence; 3498 ScenePresence presence;
3499 3499 m_sceneGraph.TryGetAvatar(agentID, out presence);
3500 lock (m_sceneGraph.ScenePresences)
3501 m_sceneGraph.ScenePresences.TryGetValue(agentID, out presence);
3502 3500
3503 if (presence != null) 3501 if (presence != null)
3504 { 3502 {
@@ -3709,8 +3707,7 @@ namespace OpenSim.Region.Framework.Scenes
3709 Vector3 lookAt, uint teleportFlags) 3707 Vector3 lookAt, uint teleportFlags)
3710 { 3708 {
3711 ScenePresence sp; 3709 ScenePresence sp;
3712 lock (m_sceneGraph.ScenePresences) 3710 m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp);
3713 m_sceneGraph.ScenePresences.TryGetValue(remoteClient.AgentId, out sp);
3714 3711
3715 if (sp != null) 3712 if (sp != null)
3716 { 3713 {
@@ -4112,7 +4109,7 @@ namespace OpenSim.Region.Framework.Scenes
4112 /// This list is a new object, so it can be iterated over without locking. 4109 /// This list is a new object, so it can be iterated over without locking.
4113 /// </summary> 4110 /// </summary>
4114 /// <returns></returns> 4111 /// <returns></returns>
4115 public List<ScenePresence> GetScenePresences() 4112 public ScenePresence[] GetScenePresences()
4116 { 4113 {
4117 return m_sceneGraph.GetScenePresences(); 4114 return m_sceneGraph.GetScenePresences();
4118 } 4115 }
@@ -4159,15 +4156,13 @@ namespace OpenSim.Region.Framework.Scenes
4159 public void ForEachScenePresence(Action<ScenePresence> action) 4156 public void ForEachScenePresence(Action<ScenePresence> action)
4160 { 4157 {
4161 // We don't want to try to send messages if there are no avatars. 4158 // We don't want to try to send messages if there are no avatars.
4162 if (m_sceneGraph != null && m_sceneGraph.ScenePresences != null) 4159 if (m_sceneGraph != null)
4163 { 4160 {
4164 try 4161 try
4165 { 4162 {
4166 List<ScenePresence> presenceList = GetScenePresences(); 4163 ScenePresence[] presences = GetScenePresences();
4167 foreach (ScenePresence presence in presenceList) 4164 for (int i = 0; i < presences.Length; i++)
4168 { 4165 action(presences[i]);
4169 action(presence);
4170 }
4171 } 4166 }
4172 catch (Exception e) 4167 catch (Exception e)
4173 { 4168 {