From 588361e2a2398b963871762c2b5485c6a086cf47 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Fri, 23 Oct 2009 01:02:36 -0700
Subject: Experimental change to use an immutable array for iterating
ScenePresences, avoiding locking and copying the list each time it is
accessed
---
OpenSim/Region/Framework/Scenes/SceneManager.cs | 53 ++++++++++++++-----------
1 file changed, 29 insertions(+), 24 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/SceneManager.cs')
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index 3097929..dfaa7ea 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -411,41 +411,46 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SetDebugPacketLevelOnCurrentScene(int newDebug)
{
- ForEachCurrentScene(delegate(Scene scene)
- {
- List scenePresences = scene.GetScenePresences();
+ ForEachCurrentScene(
+ delegate(Scene scene)
+ {
+ ScenePresence[] scenePresences = scene.GetScenePresences();
+
+ for (int i = 0; i < scenePresences.Length; i++)
+ {
+ ScenePresence scenePresence = scenePresences[i];
- foreach (ScenePresence scenePresence in scenePresences)
- {
- if (!scenePresence.IsChildAgent)
- {
- m_log.ErrorFormat("Packet debug for {0} {1} set to {2}",
- scenePresence.Firstname,
- scenePresence.Lastname,
- newDebug);
+ if (!scenePresence.IsChildAgent)
+ {
+ m_log.ErrorFormat("Packet debug for {0} {1} set to {2}",
+ scenePresence.Firstname,
+ scenePresence.Lastname,
+ newDebug);
- scenePresence.ControllingClient.SetDebugPacketLevel(newDebug);
- }
- }
- });
+ scenePresence.ControllingClient.SetDebugPacketLevel(newDebug);
+ }
+ }
+ }
+ );
}
public List GetCurrentSceneAvatars()
{
List avatars = new List();
- ForEachCurrentScene(delegate(Scene scene)
- {
- List scenePresences = scene.GetScenePresences();
-
- foreach (ScenePresence scenePresence in scenePresences)
+ ForEachCurrentScene(
+ delegate(Scene scene)
{
- if (!scenePresence.IsChildAgent)
+ ScenePresence[] scenePresences = scene.GetScenePresences();
+
+ for (int i = 0; i < scenePresences.Length; i++)
{
- avatars.Add(scenePresence);
+ ScenePresence scenePresence = scenePresences[i];
+ if (!scenePresence.IsChildAgent)
+ avatars.Add(scenePresence);
}
}
- });
+ );
return avatars;
}
@@ -456,7 +461,7 @@ namespace OpenSim.Region.Framework.Scenes
ForEachCurrentScene(delegate(Scene scene)
{
- List scenePresences = scene.GetScenePresences();
+ ScenePresence[] scenePresences = scene.GetScenePresences();
presences.AddRange(scenePresences);
});
--
cgit v1.1