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 --- .../Region/CoreModules/Avatar/Dialog/DialogModule.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Dialog') diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index ebebaf9..72ec869 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -85,10 +85,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendAlertToUser(string firstName, string lastName, string message, bool modal) { - List presenceList = m_scene.GetScenePresences(); + ScenePresence[] presenceList = m_scene.GetScenePresences(); - foreach (ScenePresence presence in presenceList) + for (int i = 0; i < presenceList.Length; i++) { + ScenePresence presence = presenceList[i]; + if (presence.Firstname == firstName && presence.Lastname == lastName) { presence.ControllingClient.SendAgentAlertMessage(message, modal); @@ -99,10 +101,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendGeneralAlert(string message) { - List presenceList = m_scene.GetScenePresences(); + ScenePresence[] presenceList = m_scene.GetScenePresences(); - foreach (ScenePresence presence in presenceList) + for (int i = 0; i < presenceList.Length; i++) { + ScenePresence presence = presenceList[i]; + if (!presence.IsChildAgent) presence.ControllingClient.SendAlertMessage(message); } @@ -150,10 +154,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendNotificationToUsersInRegion( UUID fromAvatarID, string fromAvatarName, string message) { - List presenceList = m_scene.GetScenePresences(); + ScenePresence[] presences = m_scene.GetScenePresences(); - foreach (ScenePresence presence in presenceList) + for (int i = 0; i < presences.Length; i++) { + ScenePresence presence = presences[i]; if (!presence.IsChildAgent) presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); } -- cgit v1.1