diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs index e4c85e4..5b9a45c 100644 --- a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs +++ b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs | |||
@@ -329,28 +329,12 @@ namespace OpenSim.Framework | |||
329 | 329 | ||
330 | public void ForEach(Action<TValue> action) | 330 | public void ForEach(Action<TValue> action) |
331 | { | 331 | { |
332 | bool gotLock = false; | 332 | TValue[] values = GetArray(); |
333 | 333 | if(values == null || values.Length == 0) | |
334 | try | 334 | return; |
335 | { | ||
336 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
337 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
338 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
339 | try {} | ||
340 | finally | ||
341 | { | ||
342 | rwLock.EnterReadLock(); | ||
343 | gotLock = true; | ||
344 | } | ||
345 | 335 | ||
346 | foreach (TValue value in Dictionary1.Values) | 336 | foreach (TValue value in values) |
347 | action(value); | 337 | action(value); |
348 | } | ||
349 | finally | ||
350 | { | ||
351 | if (gotLock) | ||
352 | rwLock.ExitReadLock(); | ||
353 | } | ||
354 | } | 338 | } |
355 | 339 | ||
356 | public void ForEach(Action<KeyValuePair<TKey1, TValue>> action) | 340 | public void ForEach(Action<KeyValuePair<TKey1, TValue>> action) |