* Refactored a number of locks into EntityManager to limit the scope of the locks.

0.6.1-post-fixes
Adam Frisby 2008-11-24 15:09:25 +00:00
parent 47829849d9
commit 2305ef61a5
1 changed files with 17 additions and 37 deletions

View File

@ -117,12 +117,8 @@ namespace OpenSim.Region.Environment.Scenes
ScenePresences.Clear(); ScenePresences.Clear();
} }
//SceneObjects.Clear();
lock (Entities)
{
Entities.Clear(); Entities.Clear();
} }
}
#region Update Methods #region Update Methods
@ -266,12 +262,11 @@ namespace OpenSim.Region.Environment.Scenes
sceneObject.AttachToScene(m_parentScene); sceneObject.AttachToScene(m_parentScene);
lock (Entities) lock (sceneObject)
{ {
if (!Entities.ContainsKey(sceneObject.UUID)) if (!Entities.ContainsKey(sceneObject.UUID))
{ {
// QuadTree.AddSceneObject(sceneObject); Entities.Add(sceneObject);
Entities.Add(sceneObject.UUID, sceneObject);
m_numPrim += sceneObject.Children.Count; m_numPrim += sceneObject.Children.Count;
if (attachToBackup) if (attachToBackup)
@ -279,31 +274,27 @@ namespace OpenSim.Region.Environment.Scenes
return true; return true;
} }
}
return false; return false;
} }
}
/// <summary> /// <summary>
/// Delete an object from the scene /// Delete an object from the scene
/// </summary> /// </summary>
/// <param name="sceneObject"></param>
/// <returns>true if the object was deleted, false if there was no object to delete</returns> /// <returns>true if the object was deleted, false if there was no object to delete</returns>
protected internal bool DeleteSceneObject(UUID uuid, bool resultOfObjectLinked) protected internal bool DeleteSceneObject(UUID uuid, bool resultOfObjectLinked)
{
lock (Entities)
{ {
if (Entities.ContainsKey(uuid)) if (Entities.ContainsKey(uuid))
{ {
if (!resultOfObjectLinked) if (!resultOfObjectLinked)
{ {
m_numPrim -= ((SceneObjectGroup)Entities[uuid]).Children.Count; m_numPrim -= ((SceneObjectGroup) Entities[uuid]).Children.Count;
} }
Entities.Remove(uuid); Entities.Remove(uuid);
return true; return true;
} }
}
return false; return false;
} }
@ -615,10 +606,7 @@ namespace OpenSim.Region.Environment.Scenes
presence.AddToPhysicalScene(); presence.AddToPhysicalScene();
} }
lock (Entities)
{
Entities[presence.UUID] = presence; Entities[presence.UUID] = presence;
}
lock (ScenePresences) lock (ScenePresences)
{ {
@ -630,17 +618,12 @@ namespace OpenSim.Region.Environment.Scenes
/// Remove a presence from the scene /// Remove a presence from the scene
/// </summary> /// </summary>
protected internal void RemoveScenePresence(UUID agentID) protected internal void RemoveScenePresence(UUID agentID)
{
lock (Entities)
{ {
if (!Entities.Remove(agentID)) if (!Entities.Remove(agentID))
{ {
m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", agentID); m_log.WarnFormat(
} "[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene Entities list",
// else agentID);
// {
// m_log.InfoFormat("[SCENE] Removed scene presence {0} from entities list", agentID);
// }
} }
lock (ScenePresences) lock (ScenePresences)
@ -1668,10 +1651,7 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID, true); SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID, true);
copy.AbsolutePosition = copy.AbsolutePosition + offset; copy.AbsolutePosition = copy.AbsolutePosition + offset;
lock (Entities) Entities.Add(copy);
{
Entities.Add(copy.UUID, copy);
}
// Since we copy from a source group that is in selected // Since we copy from a source group that is in selected
// state, but the copy is shown deselected in the viewer, // state, but the copy is shown deselected in the viewer,