(almost) useless change
parent
b242232c7b
commit
040ab65f68
|
@ -51,7 +51,14 @@ namespace OpenSim.Framework
|
||||||
private object m_syncRoot = new object();
|
private object m_syncRoot = new object();
|
||||||
|
|
||||||
/// <summary>Number of clients in the collection</summary>
|
/// <summary>Number of clients in the collection</summary>
|
||||||
public int Count { get { return m_dict1.Count; } }
|
public int Count
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (m_syncRoot)
|
||||||
|
return m_dict1.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
|
@ -60,7 +67,7 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
m_dict1 = new Dictionary<UUID, IClientAPI>();
|
m_dict1 = new Dictionary<UUID, IClientAPI>();
|
||||||
m_dict2 = new Dictionary<IPEndPoint, IClientAPI>();
|
m_dict2 = new Dictionary<IPEndPoint, IClientAPI>();
|
||||||
m_array = new IClientAPI[0];
|
m_array = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -74,17 +81,9 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
lock (m_syncRoot)
|
lock (m_syncRoot)
|
||||||
{
|
{
|
||||||
// allow self healing
|
|
||||||
// if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint))
|
|
||||||
// return false;
|
|
||||||
|
|
||||||
m_dict1[value.AgentId] = value;
|
m_dict1[value.AgentId] = value;
|
||||||
m_dict2[value.RemoteEndPoint] = value;
|
m_dict2[value.RemoteEndPoint] = value;
|
||||||
|
m_array = null;
|
||||||
// dict1 is the master
|
|
||||||
IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
|
|
||||||
m_dict1.Values.CopyTo(newArray, 0);
|
|
||||||
m_array = newArray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -105,10 +104,7 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
m_dict1.Remove(key);
|
m_dict1.Remove(key);
|
||||||
m_dict2.Remove(value.RemoteEndPoint);
|
m_dict2.Remove(value.RemoteEndPoint);
|
||||||
|
m_array = null;
|
||||||
IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
|
|
||||||
m_dict1.Values.CopyTo(newArray, 0);
|
|
||||||
m_array = newArray;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +120,7 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
m_dict1.Clear();
|
m_dict1.Clear();
|
||||||
m_dict2.Clear();
|
m_dict2.Clear();
|
||||||
m_array = new IClientAPI[0];
|
m_array = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +131,8 @@ namespace OpenSim.Framework
|
||||||
/// <returns>True if the UUID was found in the collection, otherwise false</returns>
|
/// <returns>True if the UUID was found in the collection, otherwise false</returns>
|
||||||
public bool ContainsKey(UUID key)
|
public bool ContainsKey(UUID key)
|
||||||
{
|
{
|
||||||
return m_dict1.ContainsKey(key);
|
lock (m_syncRoot)
|
||||||
|
return m_dict1.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -145,7 +142,8 @@ namespace OpenSim.Framework
|
||||||
/// <returns>True if the endpoint was found in the collection, otherwise false</returns>
|
/// <returns>True if the endpoint was found in the collection, otherwise false</returns>
|
||||||
public bool ContainsKey(IPEndPoint key)
|
public bool ContainsKey(IPEndPoint key)
|
||||||
{
|
{
|
||||||
return m_dict2.ContainsKey(key);
|
lock (m_syncRoot)
|
||||||
|
return m_dict2.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -156,8 +154,12 @@ namespace OpenSim.Framework
|
||||||
/// <returns>True if the lookup succeeded, otherwise false</returns>
|
/// <returns>True if the lookup succeeded, otherwise false</returns>
|
||||||
public bool TryGetValue(UUID key, out IClientAPI value)
|
public bool TryGetValue(UUID key, out IClientAPI value)
|
||||||
{
|
{
|
||||||
try { return m_dict1.TryGetValue(key, out value); }
|
try
|
||||||
catch (Exception)
|
{
|
||||||
|
lock (m_syncRoot)
|
||||||
|
return m_dict1.TryGetValue(key, out value);
|
||||||
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
value = null;
|
value = null;
|
||||||
return false;
|
return false;
|
||||||
|
@ -172,8 +174,12 @@ namespace OpenSim.Framework
|
||||||
/// <returns>True if the lookup succeeded, otherwise false</returns>
|
/// <returns>True if the lookup succeeded, otherwise false</returns>
|
||||||
public bool TryGetValue(IPEndPoint key, out IClientAPI value)
|
public bool TryGetValue(IPEndPoint key, out IClientAPI value)
|
||||||
{
|
{
|
||||||
try { return m_dict2.TryGetValue(key, out value); }
|
try
|
||||||
catch (Exception)
|
{
|
||||||
|
lock (m_syncRoot)
|
||||||
|
return m_dict2.TryGetValue(key, out value);
|
||||||
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
value = null;
|
value = null;
|
||||||
return false;
|
return false;
|
||||||
|
@ -187,7 +193,20 @@ namespace OpenSim.Framework
|
||||||
/// <param name="action">Action to perform on each element</param>
|
/// <param name="action">Action to perform on each element</param>
|
||||||
public void ForEach(Action<IClientAPI> action)
|
public void ForEach(Action<IClientAPI> action)
|
||||||
{
|
{
|
||||||
IClientAPI[] localArray = m_array;
|
IClientAPI[] localArray;
|
||||||
|
lock (m_syncRoot)
|
||||||
|
{
|
||||||
|
if (m_array == null)
|
||||||
|
{
|
||||||
|
if (m_dict1.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_array = new IClientAPI[m_dict1.Count];
|
||||||
|
m_dict1.Values.CopyTo(m_array, 0);
|
||||||
|
}
|
||||||
|
localArray = m_array;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < localArray.Length; i++)
|
for (int i = 0; i < localArray.Length; i++)
|
||||||
action(localArray[i]);
|
action(localArray[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue