aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-16 22:28:48 +0100
committerJustin Clark-Casey (justincc)2013-01-25 04:03:13 +0000
commit1650846df32872fa64a8d944f2144b866f17c57a (patch)
tree935f7e944a8a95e26de329df8f368bbbc8259b68 /OpenSim/Framework
parentEncapsulate an OSDMap in DAMap (was DynAttrsOSDMap) rather than inheriting fr... (diff)
downloadopensim-SC_OLD-1650846df32872fa64a8d944f2144b866f17c57a.zip
opensim-SC_OLD-1650846df32872fa64a8d944f2144b866f17c57a.tar.gz
opensim-SC_OLD-1650846df32872fa64a8d944f2144b866f17c57a.tar.bz2
opensim-SC_OLD-1650846df32872fa64a8d944f2144b866f17c57a.tar.xz
Lock DAMap rather than encapsulated OSDMap
This allows external lockers to preserve atomicity of dynamic attribute changes
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/DAMap.cs35
1 files changed, 18 insertions, 17 deletions
diff --git a/OpenSim/Framework/DAMap.cs b/OpenSim/Framework/DAMap.cs
index a6fdf61..7551a10 100644
--- a/OpenSim/Framework/DAMap.cs
+++ b/OpenSim/Framework/DAMap.cs
@@ -60,7 +60,8 @@ namespace OpenSim.Framework
60 { 60 {
61 //System.Console.WriteLine("Trying to deserialize [{0}]", rawXml); 61 //System.Console.WriteLine("Trying to deserialize [{0}]", rawXml);
62 62
63 m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml); 63 lock (this)
64 m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml);
64 } 65 }
65 66
66 public void ReadXml(XmlReader reader) 67 public void ReadXml(XmlReader reader)
@@ -70,7 +71,7 @@ namespace OpenSim.Framework
70 71
71 public string ToXml() 72 public string ToXml()
72 { 73 {
73 lock (m_map) 74 lock (this)
74 return OSDParser.SerializeLLSDXmlString(m_map); 75 return OSDParser.SerializeLLSDXmlString(m_map);
75 } 76 }
76 77
@@ -79,17 +80,17 @@ namespace OpenSim.Framework
79 writer.WriteRaw(ToXml()); 80 writer.WriteRaw(ToXml());
80 } 81 }
81 82
82 public int Count { get { lock (m_map) { return m_map.Count; } } } 83 public int Count { get { lock (this) { return m_map.Count; } } }
83 public bool IsReadOnly { get { return false; } } 84 public bool IsReadOnly { get { return false; } }
84 public ICollection<string> Keys { get { lock (m_map) { return m_map.Keys; } } } 85 public ICollection<string> Keys { get { lock (this) { return m_map.Keys; } } }
85 public ICollection<OSD> Values { get { lock (m_map) { return m_map.Values; } } } 86 public ICollection<OSD> Values { get { lock (this) { return m_map.Values; } } }
86 public OSD this[string key] 87 public OSD this[string key]
87 { 88 {
88 get 89 get
89 { 90 {
90 OSD llsd; 91 OSD llsd;
91 92
92 lock (m_map) 93 lock (this)
93 { 94 {
94 if (m_map.TryGetValue(key, out llsd)) 95 if (m_map.TryGetValue(key, out llsd))
95 return llsd; 96 return llsd;
@@ -97,48 +98,48 @@ namespace OpenSim.Framework
97 return null; 98 return null;
98 } 99 }
99 } 100 }
100 set { lock (m_map) { m_map[key] = value; } } 101 set { lock (this) { m_map[key] = value; } }
101 } 102 }
102 103
103 public bool ContainsKey(string key) 104 public bool ContainsKey(string key)
104 { 105 {
105 lock (m_map) 106 lock (this)
106 return m_map.ContainsKey(key); 107 return m_map.ContainsKey(key);
107 } 108 }
108 109
109 public void Add(string key, OSD llsd) 110 public void Add(string key, OSD llsd)
110 { 111 {
111 lock (m_map) 112 lock (this)
112 m_map.Add(key, llsd); 113 m_map.Add(key, llsd);
113 } 114 }
114 115
115 public void Add(KeyValuePair<string, OSD> kvp) 116 public void Add(KeyValuePair<string, OSD> kvp)
116 { 117 {
117 lock (m_map) 118 lock (this)
118 m_map.Add(kvp.Key, kvp.Value); 119 m_map.Add(kvp.Key, kvp.Value);
119 } 120 }
120 121
121 public bool Remove(string key) 122 public bool Remove(string key)
122 { 123 {
123 lock (m_map) 124 lock (this)
124 return m_map.Remove(key); 125 return m_map.Remove(key);
125 } 126 }
126 127
127 public bool TryGetValue(string key, out OSD llsd) 128 public bool TryGetValue(string key, out OSD llsd)
128 { 129 {
129 lock (m_map) 130 lock (this)
130 return m_map.TryGetValue(key, out llsd); 131 return m_map.TryGetValue(key, out llsd);
131 } 132 }
132 133
133 public void Clear() 134 public void Clear()
134 { 135 {
135 lock (m_map) 136 lock (this)
136 m_map.Clear(); 137 m_map.Clear();
137 } 138 }
138 139
139 public bool Contains(KeyValuePair<string, OSD> kvp) 140 public bool Contains(KeyValuePair<string, OSD> kvp)
140 { 141 {
141 lock (m_map) 142 lock (this)
142 return m_map.ContainsKey(kvp.Key); 143 return m_map.ContainsKey(kvp.Key);
143 } 144 }
144 145
@@ -149,13 +150,13 @@ namespace OpenSim.Framework
149 150
150 public bool Remove(KeyValuePair<string, OSD> kvp) 151 public bool Remove(KeyValuePair<string, OSD> kvp)
151 { 152 {
152 lock (m_map) 153 lock (this)
153 return m_map.Remove(kvp.Key); 154 return m_map.Remove(kvp.Key);
154 } 155 }
155 156
156 public System.Collections.IDictionaryEnumerator GetEnumerator() 157 public System.Collections.IDictionaryEnumerator GetEnumerator()
157 { 158 {
158 lock (m_map) 159 lock (this)
159 return m_map.GetEnumerator(); 160 return m_map.GetEnumerator();
160 } 161 }
161 162
@@ -166,7 +167,7 @@ namespace OpenSim.Framework
166 167
167 IEnumerator IEnumerable.GetEnumerator() 168 IEnumerator IEnumerable.GetEnumerator()
168 { 169 {
169 lock (m_map) 170 lock (this)
170 return m_map.GetEnumerator(); 171 return m_map.GetEnumerator();
171 } 172 }
172 } 173 }