more changes on scenegraph etc

0.9.1.0-post-fixes
UbitUmarov 2019-01-06 20:10:43 +00:00
parent 6e60917522
commit 950b605b42
4 changed files with 476 additions and 473 deletions

View File

@ -42,8 +42,6 @@ namespace OpenSim.Framework
Dictionary<TKey1, TValue> Dictionary1;
Dictionary<TKey2, TValue> Dictionary2;
private TValue[] m_array;
private int m_lastArrayVersion;
private int m_arrayVersion;
ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim();
@ -51,21 +49,19 @@ namespace OpenSim.Framework
{
Dictionary1 = new Dictionary<TKey1,TValue>();
Dictionary2 = new Dictionary<TKey2,TValue>();
m_array = new TValue[0];
m_lastArrayVersion = 0;
m_arrayVersion = 0;
m_array = null;
}
public DoubleDictionaryThreadAbortSafe(int capacity)
{
Dictionary1 = new Dictionary<TKey1, TValue>(capacity);
Dictionary2 = new Dictionary<TKey2, TValue>(capacity);
m_lastArrayVersion = 0;
m_arrayVersion = 0;
m_array = null;
}
~DoubleDictionaryThreadAbortSafe()
{
if(rwLock != null)
rwLock.Dispose();
}
@ -83,6 +79,8 @@ namespace OpenSim.Framework
{
rwLock.EnterWriteLock();
gotLock = true;
}
/*
if (Dictionary1.ContainsKey(key1))
{
if (!Dictionary2.ContainsKey(key2))
@ -93,10 +91,10 @@ namespace OpenSim.Framework
if (!Dictionary1.ContainsKey(key1))
throw new ArgumentException("key2 exists in the dictionary but not key1");
}
*/
Dictionary1[key1] = value;
Dictionary2[key2] = value;
++m_arrayVersion;
}
m_array = null;
}
finally
{
@ -120,10 +118,10 @@ namespace OpenSim.Framework
{
rwLock.EnterWriteLock();
gotLock = true;
Dictionary1.Remove(key1);
success = Dictionary2.Remove(key2);
++m_arrayVersion;
}
success = Dictionary1.Remove(key1);
success &= Dictionary2.Remove(key2);
m_array = null;
}
finally
{
@ -164,7 +162,7 @@ namespace OpenSim.Framework
{
Dictionary1.Remove(key1);
Dictionary2.Remove(kvp.Key);
++m_arrayVersion;
m_array = null;
}
found = true;
break;
@ -211,7 +209,7 @@ namespace OpenSim.Framework
{
Dictionary2.Remove(key2);
Dictionary1.Remove(kvp.Key);
++m_arrayVersion;
m_array = null;
}
found = true;
break;
@ -244,9 +242,7 @@ namespace OpenSim.Framework
gotLock = true;
Dictionary1.Clear();
Dictionary2.Clear();
m_array = new TValue[0];
m_arrayVersion = 0;
m_lastArrayVersion = 0;
m_array = null;
}
}
finally
@ -391,30 +387,12 @@ namespace OpenSim.Framework
public TValue FindValue(Predicate<TValue> predicate)
{
bool gotLock = false;
try
TValue[] values = GetArray();
int len = values.Length;
for (int i = 0; i < len; ++i)
{
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
try {}
finally
{
rwLock.EnterReadLock();
gotLock = true;
}
foreach (TValue value in Dictionary1.Values)
{
if (predicate(value))
return value;
}
}
finally
{
if (gotLock)
rwLock.ExitReadLock();
if (predicate(values[i]))
return values[i];
}
return default(TValue);
@ -423,32 +401,14 @@ namespace OpenSim.Framework
public IList<TValue> FindAll(Predicate<TValue> predicate)
{
IList<TValue> list = new List<TValue>();
bool gotLock = false;
TValue[] values = GetArray();
try
int len = values.Length;
for (int i = 0; i < len; ++i)
{
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
try {}
finally
{
rwLock.EnterReadLock();
gotLock = true;
if (predicate(values[i]))
list.Add(values[i]);
}
foreach (TValue value in Dictionary1.Values)
{
if (predicate(value))
list.Add(value);
}
}
finally
{
if (gotLock)
rwLock.ExitReadLock();
}
return list;
}
@ -497,7 +457,7 @@ namespace OpenSim.Framework
for (int i = 0; i < list2.Count; i++)
Dictionary2.Remove(list2[i]);
++m_arrayVersion;
m_array = null;
}
}
finally
@ -527,12 +487,10 @@ namespace OpenSim.Framework
rwLock.EnterWriteLock();
gotLock = true;
if (m_lastArrayVersion != m_arrayVersion)
if (m_array == null)
{
TValue[] array = new TValue[Dictionary1.Count];
Dictionary1.Values.CopyTo(array, 0);
m_array = array;
m_lastArrayVersion = m_arrayVersion;
m_array = new TValue[Dictionary1.Count];
Dictionary1.Values.CopyTo(m_array, 0);
}
ret = m_array;
}

View File

@ -41,8 +41,6 @@ namespace OpenSim.Framework
{
private Dictionary<TKey, TValue> m_dict;
private TValue[] m_array;
private int m_lastArrayVersion;
private int m_arrayVersion;
/// <summary>Number of values currently stored in the collection</summary>
public int Count { get { return m_dict.Count; } }
@ -59,9 +57,7 @@ namespace OpenSim.Framework
public MapAndArray()
{
m_dict = new Dictionary<TKey, TValue>();
m_array = new TValue[0];
m_lastArrayVersion = 0;
m_arrayVersion = 0;
m_array = null;
}
/// <summary>
@ -71,9 +67,7 @@ namespace OpenSim.Framework
public MapAndArray(int capacity)
{
m_dict = new Dictionary<TKey, TValue>(capacity);
m_array = new TValue[0];
m_lastArrayVersion = 0;
m_arrayVersion = 0;
m_array = null;
}
/// <summary>
@ -91,7 +85,7 @@ namespace OpenSim.Framework
bool containedKey = m_dict.ContainsKey(key);
m_dict[key] = value;
++m_arrayVersion;
m_array = null;
return !containedKey;
}
@ -109,7 +103,7 @@ namespace OpenSim.Framework
lock (m_syncRoot)
{
m_dict.Add(key, value);
++m_arrayVersion;
m_array = null;
return m_dict.Count;
}
}
@ -124,7 +118,7 @@ namespace OpenSim.Framework
lock (m_syncRoot)
{
bool removed = m_dict.Remove(key);
++m_arrayVersion;
m_array = null;
return removed;
}
}
@ -163,9 +157,7 @@ namespace OpenSim.Framework
lock (m_syncRoot)
{
m_dict = new Dictionary<TKey, TValue>();
m_array = new TValue[0];
m_lastArrayVersion = 0;
m_arrayVersion = 0;
m_array = null;
}
}
@ -179,12 +171,10 @@ namespace OpenSim.Framework
{
lock (m_syncRoot)
{
if(m_lastArrayVersion != m_arrayVersion)
if (m_array == null)
{
TValue[] array = new TValue[m_dict.Count];
m_dict.Values.CopyTo(array, 0);
m_array = array;
m_lastArrayVersion = m_arrayVersion;
m_array = new TValue[m_dict.Count];
m_dict.Values.CopyTo(m_array, 0);
}
return m_array;
}

View File

@ -2796,12 +2796,6 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
public void updateScenePartGroup(SceneObjectPart part, SceneObjectGroup grp)
{
m_sceneGraph.updateScenePartGroup(part, grp);
}
/* not in use, outdate by async method
/// <summary>
/// Move the given scene object into a new region depending on which region its absolute position has moved
@ -5065,16 +5059,6 @@ Label_GroupsDone:
#region SceneGraph wrapper methods
/// <summary>
///
/// </summary>
/// <param name="localID"></param>
/// <returns></returns>
public UUID ConvertLocalIDToFullID(uint localID)
{
return m_sceneGraph.ConvertLocalIDToFullID(localID);
}
public void SwapRootAgentCount(bool rootChildChildRootTF)
{
m_sceneGraph.SwapRootChildAgent(rootChildChildRootTF);

File diff suppressed because it is too large Load Diff