Eased the locking times of ScenePresences. No locks were removed, just the locking periods changed.

* Added an additional lock in GetScenePresences()
* Changed ForEachClient to use GetScenePresences() instead of the main ScenePresences dictionary, so that there is no need to lock.
This commit is contained in:
diva
2009-01-15 23:37:49 +00:00
parent d1456554f2
commit e80dcfa9f6
2 changed files with 44 additions and 28 deletions

View File

@@ -774,7 +774,10 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
protected internal List<ScenePresence> GetScenePresences()
{
return new List<ScenePresence>(ScenePresences.Values);
lock (ScenePresences)
{
return new List<ScenePresence>(ScenePresences.Values);
}
}
protected internal List<ScenePresence> GetAvatars()
@@ -1085,12 +1088,18 @@ namespace OpenSim.Region.Environment.Scenes
protected internal void ForEachClient(Action<IClientAPI> action)
{
lock (ScenePresences)
List<ScenePresence> splist = GetScenePresences();
foreach (ScenePresence presence in splist)
{
foreach (ScenePresence presence in ScenePresences.Values)
try
{
action(presence.ControllingClient);
}
catch (Exception e)
{
// Catch it and move on. This includes situations where splist has inconsistent info
m_log.WarnFormat("[SCENE]: Problem processing action in ForEachClient: ", e.Message);
}
}
}