diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs index 4ff8cba..55ec13e 100644 --- a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs +++ b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs | |||
@@ -69,7 +69,7 @@ namespace OpenSim.Framework | |||
69 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 69 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
70 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 70 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
71 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 71 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
72 | try {} | 72 | try {} |
73 | finally | 73 | finally |
74 | { | 74 | { |
75 | rwLock.EnterWriteLock(); | 75 | rwLock.EnterWriteLock(); |
@@ -90,10 +90,10 @@ namespace OpenSim.Framework | |||
90 | Dictionary1[key1] = value; | 90 | Dictionary1[key1] = value; |
91 | Dictionary2[key2] = value; | 91 | Dictionary2[key2] = value; |
92 | } | 92 | } |
93 | finally | 93 | finally |
94 | { | 94 | { |
95 | if (gotLock) | 95 | if (gotLock) |
96 | rwLock.ExitWriteLock(); | 96 | rwLock.ExitWriteLock(); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
@@ -107,7 +107,7 @@ namespace OpenSim.Framework | |||
107 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 107 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
108 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 108 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
109 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 109 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
110 | try {} | 110 | try {} |
111 | finally | 111 | finally |
112 | { | 112 | { |
113 | rwLock.EnterWriteLock(); | 113 | rwLock.EnterWriteLock(); |
@@ -117,10 +117,10 @@ namespace OpenSim.Framework | |||
117 | Dictionary1.Remove(key1); | 117 | Dictionary1.Remove(key1); |
118 | success = Dictionary2.Remove(key2); | 118 | success = Dictionary2.Remove(key2); |
119 | } | 119 | } |
120 | finally | 120 | finally |
121 | { | 121 | { |
122 | if (gotLock) | 122 | if (gotLock) |
123 | rwLock.ExitWriteLock(); | 123 | rwLock.ExitWriteLock(); |
124 | } | 124 | } |
125 | 125 | ||
126 | return success; | 126 | return success; |
@@ -136,7 +136,7 @@ namespace OpenSim.Framework | |||
136 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 136 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
137 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 137 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
138 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 138 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
139 | try {} | 139 | try {} |
140 | finally | 140 | finally |
141 | { | 141 | { |
142 | rwLock.EnterWriteLock(); | 142 | rwLock.EnterWriteLock(); |
@@ -159,10 +159,10 @@ namespace OpenSim.Framework | |||
159 | } | 159 | } |
160 | } | 160 | } |
161 | } | 161 | } |
162 | finally | 162 | finally |
163 | { | 163 | { |
164 | if (gotLock) | 164 | if (gotLock) |
165 | rwLock.ExitWriteLock(); | 165 | rwLock.ExitWriteLock(); |
166 | } | 166 | } |
167 | 167 | ||
168 | return found; | 168 | return found; |
@@ -178,7 +178,7 @@ namespace OpenSim.Framework | |||
178 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 178 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
179 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 179 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
180 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 180 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
181 | try {} | 181 | try {} |
182 | finally | 182 | finally |
183 | { | 183 | { |
184 | rwLock.EnterWriteLock(); | 184 | rwLock.EnterWriteLock(); |
@@ -201,10 +201,10 @@ namespace OpenSim.Framework | |||
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | finally | 204 | finally |
205 | { | 205 | { |
206 | if (gotLock) | 206 | if (gotLock) |
207 | rwLock.ExitWriteLock(); | 207 | rwLock.ExitWriteLock(); |
208 | } | 208 | } |
209 | 209 | ||
210 | return found; | 210 | return found; |
@@ -219,7 +219,7 @@ namespace OpenSim.Framework | |||
219 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 219 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
220 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 220 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
221 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 221 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
222 | try {} | 222 | try {} |
223 | finally | 223 | finally |
224 | { | 224 | { |
225 | rwLock.EnterWriteLock(); | 225 | rwLock.EnterWriteLock(); |
@@ -229,10 +229,10 @@ namespace OpenSim.Framework | |||
229 | Dictionary1.Clear(); | 229 | Dictionary1.Clear(); |
230 | Dictionary2.Clear(); | 230 | Dictionary2.Clear(); |
231 | } | 231 | } |
232 | finally | 232 | finally |
233 | { | 233 | { |
234 | if (gotLock) | 234 | if (gotLock) |
235 | rwLock.ExitWriteLock(); | 235 | rwLock.ExitWriteLock(); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
@@ -256,24 +256,24 @@ namespace OpenSim.Framework | |||
256 | bool success; | 256 | bool success; |
257 | bool gotLock = false; | 257 | bool gotLock = false; |
258 | 258 | ||
259 | try | 259 | try |
260 | { | 260 | { |
261 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 261 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
262 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 262 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
263 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 263 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
264 | try {} | 264 | try {} |
265 | finally | 265 | finally |
266 | { | 266 | { |
267 | rwLock.EnterReadLock(); | 267 | rwLock.EnterReadLock(); |
268 | gotLock = true; | 268 | gotLock = true; |
269 | } | 269 | } |
270 | 270 | ||
271 | success = Dictionary1.TryGetValue(key, out value); | 271 | success = Dictionary1.TryGetValue(key, out value); |
272 | } | 272 | } |
273 | finally | 273 | finally |
274 | { | 274 | { |
275 | if (gotLock) | 275 | if (gotLock) |
276 | rwLock.ExitReadLock(); | 276 | rwLock.ExitReadLock(); |
277 | } | 277 | } |
278 | 278 | ||
279 | return success; | 279 | return success; |
@@ -284,24 +284,24 @@ namespace OpenSim.Framework | |||
284 | bool success; | 284 | bool success; |
285 | bool gotLock = false; | 285 | bool gotLock = false; |
286 | 286 | ||
287 | try | 287 | try |
288 | { | 288 | { |
289 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 289 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
290 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 290 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
291 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 291 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
292 | try {} | 292 | try {} |
293 | finally | 293 | finally |
294 | { | 294 | { |
295 | rwLock.EnterReadLock(); | 295 | rwLock.EnterReadLock(); |
296 | gotLock = true; | 296 | gotLock = true; |
297 | } | 297 | } |
298 | 298 | ||
299 | success = Dictionary2.TryGetValue(key, out value); | 299 | success = Dictionary2.TryGetValue(key, out value); |
300 | } | 300 | } |
301 | finally | 301 | finally |
302 | { | 302 | { |
303 | if (gotLock) | 303 | if (gotLock) |
304 | rwLock.ExitReadLock(); | 304 | rwLock.ExitReadLock(); |
305 | } | 305 | } |
306 | 306 | ||
307 | return success; | 307 | return success; |
@@ -316,7 +316,7 @@ namespace OpenSim.Framework | |||
316 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 316 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
317 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 317 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
318 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 318 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
319 | try {} | 319 | try {} |
320 | finally | 320 | finally |
321 | { | 321 | { |
322 | rwLock.EnterReadLock(); | 322 | rwLock.EnterReadLock(); |
@@ -326,10 +326,10 @@ namespace OpenSim.Framework | |||
326 | foreach (TValue value in Dictionary1.Values) | 326 | foreach (TValue value in Dictionary1.Values) |
327 | action(value); | 327 | action(value); |
328 | } | 328 | } |
329 | finally | 329 | finally |
330 | { | 330 | { |
331 | if (gotLock) | 331 | if (gotLock) |
332 | rwLock.ExitReadLock(); | 332 | rwLock.ExitReadLock(); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
@@ -342,7 +342,7 @@ namespace OpenSim.Framework | |||
342 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 342 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
343 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 343 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
344 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 344 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
345 | try {} | 345 | try {} |
346 | finally | 346 | finally |
347 | { | 347 | { |
348 | rwLock.EnterReadLock(); | 348 | rwLock.EnterReadLock(); |
@@ -352,10 +352,10 @@ namespace OpenSim.Framework | |||
352 | foreach (KeyValuePair<TKey1, TValue> entry in Dictionary1) | 352 | foreach (KeyValuePair<TKey1, TValue> entry in Dictionary1) |
353 | action(entry); | 353 | action(entry); |
354 | } | 354 | } |
355 | finally | 355 | finally |
356 | { | 356 | { |
357 | if (gotLock) | 357 | if (gotLock) |
358 | rwLock.ExitReadLock(); | 358 | rwLock.ExitReadLock(); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
@@ -368,7 +368,7 @@ namespace OpenSim.Framework | |||
368 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 368 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
369 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 369 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
370 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 370 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
371 | try {} | 371 | try {} |
372 | finally | 372 | finally |
373 | { | 373 | { |
374 | rwLock.EnterReadLock(); | 374 | rwLock.EnterReadLock(); |
@@ -378,10 +378,10 @@ namespace OpenSim.Framework | |||
378 | foreach (KeyValuePair<TKey2, TValue> entry in Dictionary2) | 378 | foreach (KeyValuePair<TKey2, TValue> entry in Dictionary2) |
379 | action(entry); | 379 | action(entry); |
380 | } | 380 | } |
381 | finally | 381 | finally |
382 | { | 382 | { |
383 | if (gotLock) | 383 | if (gotLock) |
384 | rwLock.ExitReadLock(); | 384 | rwLock.ExitReadLock(); |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
@@ -394,7 +394,7 @@ namespace OpenSim.Framework | |||
394 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 394 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
395 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 395 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
396 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 396 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
397 | try {} | 397 | try {} |
398 | finally | 398 | finally |
399 | { | 399 | { |
400 | rwLock.EnterReadLock(); | 400 | rwLock.EnterReadLock(); |
@@ -407,10 +407,10 @@ namespace OpenSim.Framework | |||
407 | return value; | 407 | return value; |
408 | } | 408 | } |
409 | } | 409 | } |
410 | finally | 410 | finally |
411 | { | 411 | { |
412 | if (gotLock) | 412 | if (gotLock) |
413 | rwLock.ExitReadLock(); | 413 | rwLock.ExitReadLock(); |
414 | } | 414 | } |
415 | 415 | ||
416 | return default(TValue); | 416 | return default(TValue); |
@@ -426,7 +426,7 @@ namespace OpenSim.Framework | |||
426 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 426 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
427 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 427 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
428 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 428 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
429 | try {} | 429 | try {} |
430 | finally | 430 | finally |
431 | { | 431 | { |
432 | rwLock.EnterReadLock(); | 432 | rwLock.EnterReadLock(); |
@@ -439,10 +439,10 @@ namespace OpenSim.Framework | |||
439 | list.Add(value); | 439 | list.Add(value); |
440 | } | 440 | } |
441 | } | 441 | } |
442 | finally | 442 | finally |
443 | { | 443 | { |
444 | if (gotLock) | 444 | if (gotLock) |
445 | rwLock.ExitReadLock(); | 445 | rwLock.ExitReadLock(); |
446 | } | 446 | } |
447 | 447 | ||
448 | return list; | 448 | return list; |
@@ -458,7 +458,7 @@ namespace OpenSim.Framework | |||
458 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | 458 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing |
459 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | 459 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot |
460 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | 460 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). |
461 | try {} | 461 | try {} |
462 | finally | 462 | finally |
463 | { | 463 | { |
464 | rwLock.EnterUpgradeableReadLock(); | 464 | rwLock.EnterUpgradeableReadLock(); |
@@ -482,7 +482,7 @@ namespace OpenSim.Framework | |||
482 | 482 | ||
483 | try | 483 | try |
484 | { | 484 | { |
485 | try {} | 485 | try {} |
486 | finally | 486 | finally |
487 | { | 487 | { |
488 | rwLock.EnterUpgradeableReadLock(); | 488 | rwLock.EnterUpgradeableReadLock(); |
@@ -495,16 +495,16 @@ namespace OpenSim.Framework | |||
495 | for (int i = 0; i < list2.Count; i++) | 495 | for (int i = 0; i < list2.Count; i++) |
496 | Dictionary2.Remove(list2[i]); | 496 | Dictionary2.Remove(list2[i]); |
497 | } | 497 | } |
498 | finally | 498 | finally |
499 | { | 499 | { |
500 | if (gotWriteLock) | 500 | if (gotWriteLock) |
501 | rwLock.ExitWriteLock(); | 501 | rwLock.ExitWriteLock(); |
502 | } | 502 | } |
503 | } | 503 | } |
504 | finally | 504 | finally |
505 | { | 505 | { |
506 | if (gotUpgradeableLock) | 506 | if (gotUpgradeableLock) |
507 | rwLock.ExitUpgradeableReadLock(); | 507 | rwLock.ExitUpgradeableReadLock(); |
508 | } | 508 | } |
509 | 509 | ||
510 | return list.Count; | 510 | return list.Count; |