From 47829849d99e1ec6e11ac26e1f892cbaf94d5503 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 24 Nov 2008 14:45:05 +0000 Subject: * Swaps Scene.Entities Dictionary for EntityManager. * Important Changes: Scene.Entities is now IEnumerable directly. You do not need to use Entities.Values, you can Enumerate on .Entities directly. (So 'foreach Scene.Entities' vs 'foreach Scene.Entities.Values'). * Locks: Entities maintains it's own internal locking states. This means you do not need to lock entities anymore. I'll be going through and removing locks on it systematically. --- OpenSim/Region/Environment/Scenes/EntityManager.cs | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/EntityManager.cs') diff --git a/OpenSim/Region/Environment/Scenes/EntityManager.cs b/OpenSim/Region/Environment/Scenes/EntityManager.cs index 43bf090..be39878 100644 --- a/OpenSim/Region/Environment/Scenes/EntityManager.cs +++ b/OpenSim/Region/Environment/Scenes/EntityManager.cs @@ -71,21 +71,25 @@ namespace OpenSim.Region.Environment.Scenes } } - public void Remove(uint localID) + public bool Remove(uint localID) { lock(m_lock) { - m_eb_uuid.Remove(m_eb_localID[localID].UUID); - m_eb_localID.Remove(localID); + bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID); + bool b = m_eb_localID.Remove(localID); + + return a && b; } } - public void Remove(UUID id) + public bool Remove(UUID id) { lock(m_lock) { - m_eb_localID.Remove(m_eb_uuid[id].LocalId); - m_eb_uuid.Remove(id); + bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId); + bool b = m_eb_uuid.Remove(id); + + return a && b; } } @@ -145,6 +149,22 @@ namespace OpenSim.Region.Environment.Scenes } } + public bool TryGetValue(UUID key, out EntityBase obj) + { + lock(m_lock) + { + return m_eb_uuid.TryGetValue(key, out obj); + } + } + + public bool TryGetValue(uint key, out EntityBase obj) + { + lock (m_lock) + { + return m_eb_localID.TryGetValue(key, out obj); + } + } + /// /// This could be optimised to work on the list 'live' rather than making a safe copy and iterating that. /// -- cgit v1.1