Make locking more uniform

cpu-performance
BlueWall 2013-06-05 15:08:25 -04:00
parent b5d0ac4c42
commit b4f472c4fa
1 changed files with 22 additions and 17 deletions

View File

@ -62,6 +62,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
// count. The entries are removed when the interest count reaches 0. // count. The entries are removed when the interest count reaches 0.
Dictionary<UUID,UUID> classifiedCache = new Dictionary<UUID, UUID>(); Dictionary<UUID,UUID> classifiedCache = new Dictionary<UUID, UUID>();
Dictionary<UUID,int> classifiedInterest = new Dictionary<UUID, int>(); Dictionary<UUID,int> classifiedInterest = new Dictionary<UUID, int>();
Object classifiedLock;
public Scene Scene public Scene Scene
{ {
@ -329,11 +330,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
if(!classifiedCache.ContainsKey(cid)) if(!classifiedCache.ContainsKey(cid))
{ {
classifiedCache.Add(cid,creatorId); // lock(classifiedLock)
classifiedInterest.Add(cid, 0); // {
lock(classifiedCache)
classifiedCache.Add(cid,creatorId);
lock(classifiedInterest)
classifiedInterest.Add(cid, 0);
// }
} }
classifiedInterest[cid] ++; lock(classifiedInterest)
classifiedInterest[cid] ++;
} }
remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds); remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
@ -349,20 +356,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
{ {
target = classifiedCache[queryClassifiedID]; target = classifiedCache[queryClassifiedID];
if(classifiedInterest[queryClassifiedID] -- == 0) lock(classifiedInterest)
classifiedInterest[queryClassifiedID] --;
if(classifiedInterest[queryClassifiedID] == 0)
{ {
lock(classifiedInterest)
classifiedInterest.Remove(queryClassifiedID);
lock(classifiedCache) lock(classifiedCache)
{
lock(classifiedInterest)
{
classifiedInterest.Remove(queryClassifiedID);
}
classifiedCache.Remove(queryClassifiedID); classifiedCache.Remove(queryClassifiedID);
}
} }
} }
string serverURI = string.Empty; string serverURI = string.Empty;
bool foreign = GetUserProfileServerURI(target, out serverURI); bool foreign = GetUserProfileServerURI(target, out serverURI);