aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs
diff options
context:
space:
mode:
authorUbitUmarov2019-01-06 02:23:49 +0000
committerUbitUmarov2019-01-06 02:23:49 +0000
commit6e609175224791eb1be9f0ce77ffa64fb9b57038 (patch)
tree206b9442fd584a263212eedc022942219fc36c01 /OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs
parentlet DoubleDictionary... also have a values array (diff)
downloadopensim-SC-6e609175224791eb1be9f0ce77ffa64fb9b57038.zip
opensim-SC-6e609175224791eb1be9f0ce77ffa64fb9b57038.tar.gz
opensim-SC-6e609175224791eb1be9f0ce77ffa64fb9b57038.tar.bz2
opensim-SC-6e609175224791eb1be9f0ce77ffa64fb9b57038.tar.xz
change its foreach
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs26
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)