Lock DAMap rather than encapsulated OSDMap

This allows external lockers to preserve atomicity of dynamic attribute changes
user_profiles
Justin Clark-Casey (justincc) 2010-08-16 22:28:48 +01:00
parent a6d9c26365
commit 1650846df3
1 changed files with 18 additions and 17 deletions

View File

@ -60,6 +60,7 @@ namespace OpenSim.Framework
{ {
//System.Console.WriteLine("Trying to deserialize [{0}]", rawXml); //System.Console.WriteLine("Trying to deserialize [{0}]", rawXml);
lock (this)
m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml); m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml);
} }
@ -70,7 +71,7 @@ namespace OpenSim.Framework
public string ToXml() public string ToXml()
{ {
lock (m_map) lock (this)
return OSDParser.SerializeLLSDXmlString(m_map); return OSDParser.SerializeLLSDXmlString(m_map);
} }
@ -79,17 +80,17 @@ namespace OpenSim.Framework
writer.WriteRaw(ToXml()); writer.WriteRaw(ToXml());
} }
public int Count { get { lock (m_map) { return m_map.Count; } } } public int Count { get { lock (this) { return m_map.Count; } } }
public bool IsReadOnly { get { return false; } } public bool IsReadOnly { get { return false; } }
public ICollection<string> Keys { get { lock (m_map) { return m_map.Keys; } } } public ICollection<string> Keys { get { lock (this) { return m_map.Keys; } } }
public ICollection<OSD> Values { get { lock (m_map) { return m_map.Values; } } } public ICollection<OSD> Values { get { lock (this) { return m_map.Values; } } }
public OSD this[string key] public OSD this[string key]
{ {
get get
{ {
OSD llsd; OSD llsd;
lock (m_map) lock (this)
{ {
if (m_map.TryGetValue(key, out llsd)) if (m_map.TryGetValue(key, out llsd))
return llsd; return llsd;
@ -97,48 +98,48 @@ namespace OpenSim.Framework
return null; return null;
} }
} }
set { lock (m_map) { m_map[key] = value; } } set { lock (this) { m_map[key] = value; } }
} }
public bool ContainsKey(string key) public bool ContainsKey(string key)
{ {
lock (m_map) lock (this)
return m_map.ContainsKey(key); return m_map.ContainsKey(key);
} }
public void Add(string key, OSD llsd) public void Add(string key, OSD llsd)
{ {
lock (m_map) lock (this)
m_map.Add(key, llsd); m_map.Add(key, llsd);
} }
public void Add(KeyValuePair<string, OSD> kvp) public void Add(KeyValuePair<string, OSD> kvp)
{ {
lock (m_map) lock (this)
m_map.Add(kvp.Key, kvp.Value); m_map.Add(kvp.Key, kvp.Value);
} }
public bool Remove(string key) public bool Remove(string key)
{ {
lock (m_map) lock (this)
return m_map.Remove(key); return m_map.Remove(key);
} }
public bool TryGetValue(string key, out OSD llsd) public bool TryGetValue(string key, out OSD llsd)
{ {
lock (m_map) lock (this)
return m_map.TryGetValue(key, out llsd); return m_map.TryGetValue(key, out llsd);
} }
public void Clear() public void Clear()
{ {
lock (m_map) lock (this)
m_map.Clear(); m_map.Clear();
} }
public bool Contains(KeyValuePair<string, OSD> kvp) public bool Contains(KeyValuePair<string, OSD> kvp)
{ {
lock (m_map) lock (this)
return m_map.ContainsKey(kvp.Key); return m_map.ContainsKey(kvp.Key);
} }
@ -149,13 +150,13 @@ namespace OpenSim.Framework
public bool Remove(KeyValuePair<string, OSD> kvp) public bool Remove(KeyValuePair<string, OSD> kvp)
{ {
lock (m_map) lock (this)
return m_map.Remove(kvp.Key); return m_map.Remove(kvp.Key);
} }
public System.Collections.IDictionaryEnumerator GetEnumerator() public System.Collections.IDictionaryEnumerator GetEnumerator()
{ {
lock (m_map) lock (this)
return m_map.GetEnumerator(); return m_map.GetEnumerator();
} }
@ -166,7 +167,7 @@ namespace OpenSim.Framework
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
lock (m_map) lock (this)
return m_map.GetEnumerator(); return m_map.GetEnumerator();
} }
} }