From dc633ee768635799d5b0bf5e2ada79e692a7144e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 29 Jan 2019 21:16:28 +0000 Subject: cosmetics --- .../Framework/DoubleDictionaryThreadAbortSafe.cs | 36 ++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs index 73d0d20..ec26b43 100644 --- a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs +++ b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs @@ -477,30 +477,48 @@ namespace OpenSim.Framework public TValue[] GetArray() { - TValue[] ret = new TValue[0]; - bool gotLock = false; + bool gotupLock = false; try { try { } finally { - rwLock.EnterWriteLock(); - gotLock = true; + rwLock.EnterUpgradeableReadLock(); + gotupLock = true; + } - if (m_array == null) + if (m_array == null) + { + bool gotwritelock = false; + try { + try { } + finally + { + rwLock.EnterWriteLock(); + gotwritelock = true; + } + m_array = new TValue[Dictionary1.Count]; Dictionary1.Values.CopyTo(m_array, 0); } - ret = m_array; + finally + { + if (gotwritelock) + rwLock.ExitWriteLock(); + } } + return m_array; + } + catch + { + return new TValue[0]; } finally { - if (gotLock) - rwLock.ExitWriteLock(); + if (gotupLock) + rwLock.ExitUpgradeableReadLock(); } - return ret; } } } \ No newline at end of file -- cgit v1.1