From 860b2a502f797e5822c6705d4639f370f3ac5861 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 16 Sep 2010 17:30:46 -0700 Subject: Changed SceneObjectGroup to store parts with the fast and thread-safe MapAndArray collection --- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 58 ++++++++++------------ 1 file changed, 26 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 9a01a28..a86223c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -46,13 +46,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void ForceInventoryPersistence() { - lock (m_parts) - { - foreach (SceneObjectPart part in m_parts.Values) - { - part.Inventory.ForceInventoryPersistence(); - } - } + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].Inventory.ForceInventoryPersistence(); } /// @@ -64,10 +60,9 @@ namespace OpenSim.Region.Framework.Scenes // Don't start scripts if they're turned off in the region! if (!m_scene.RegionInfo.RegionSettings.DisableScripts) { - foreach (SceneObjectPart part in m_parts.Values) - { - part.Inventory.CreateScriptInstances(startParam, postOnRez, engine, stateSource); - } + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].Inventory.CreateScriptInstances(startParam, postOnRez, engine, stateSource); } } @@ -80,13 +75,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void RemoveScriptInstances(bool sceneObjectBeingDeleted) { - lock (m_parts) - { - foreach (SceneObjectPart part in m_parts.Values) - { - part.Inventory.RemoveScriptInstances(sceneObjectBeingDeleted); - } - } + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].Inventory.RemoveScriptInstances(sceneObjectBeingDeleted); } /// @@ -283,8 +274,11 @@ namespace OpenSim.Region.Framework.Scenes PermissionMask.Transfer) | 7; uint ownerMask = 0x7fffffff; - foreach (SceneObjectPart part in m_parts.Values) + + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) { + SceneObjectPart part = parts[i]; ownerMask &= part.OwnerMask; perms &= part.Inventory.MaskEffectivePermissions(); } @@ -312,39 +306,40 @@ namespace OpenSim.Region.Framework.Scenes public void ApplyNextOwnerPermissions() { - foreach (SceneObjectPart part in m_parts.Values) - { - part.ApplyNextOwnerPermissions(); - } + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].ApplyNextOwnerPermissions(); } public string GetStateSnapshot() { Dictionary states = new Dictionary(); - foreach (SceneObjectPart part in m_parts.Values) + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) { + SceneObjectPart part = parts[i]; foreach (KeyValuePair s in part.Inventory.GetScriptStates()) states[s.Key] = s.Value; } if (states.Count < 1) - return ""; + return String.Empty; XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, - "", ""); + String.Empty, String.Empty); xmldoc.AppendChild(xmlnode); XmlElement rootElement = xmldoc.CreateElement("", "ScriptData", - ""); + String.Empty); xmldoc.AppendChild(rootElement); XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates", - ""); + String.Empty); rootElement.AppendChild(wrapper); @@ -424,10 +419,9 @@ namespace OpenSim.Region.Framework.Scenes public void ResumeScripts() { - foreach (SceneObjectPart part in m_parts.Values) - { - part.Inventory.ResumeScripts(); - } + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].Inventory.ResumeScripts(); } } } -- cgit v1.1