remove a Paralell.For (actually not used). That kind of fine gained multitask makes no sense on already heavy multitasked server application like opensim. CPU cores are already busy or needed elsewhere.

0.9.0-post-fixes
UbitUmarov 2017-05-15 18:10:08 +01:00
parent 7f163e8f76
commit c74e0e2d9b
1 changed files with 9 additions and 39 deletions

View File

@ -27,10 +27,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using System.Net; using System.Net;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
@ -76,20 +74,16 @@ namespace OpenSim.Framework
{ {
lock (m_syncRoot) lock (m_syncRoot)
{ {
if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint)) // allow self healing
return false; // 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;
IClientAPI[] oldArray = m_array; // dict1 is the master
int oldLength = oldArray.Length; IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
m_dict1.Values.CopyTo(newArray, 0);
IClientAPI[] newArray = new IClientAPI[oldLength + 1];
for (int i = 0; i < oldLength; i++)
newArray[i] = oldArray[i];
newArray[oldLength] = value;
m_array = newArray; m_array = newArray;
} }
@ -112,22 +106,12 @@ namespace OpenSim.Framework
m_dict1.Remove(key); m_dict1.Remove(key);
m_dict2.Remove(value.RemoteEndPoint); m_dict2.Remove(value.RemoteEndPoint);
IClientAPI[] oldArray = m_array; IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
int oldLength = oldArray.Length; m_dict1.Values.CopyTo(newArray, 0);
IClientAPI[] newArray = new IClientAPI[oldLength - 1];
int j = 0;
for (int i = 0; i < oldLength; i++)
{
if (oldArray[i] != value)
newArray[j++] = oldArray[i];
}
m_array = newArray; m_array = newArray;
return true; return true;
} }
} }
return false; return false;
} }
@ -196,26 +180,12 @@ namespace OpenSim.Framework
} }
} }
/// <summary>
/// Performs a given task in parallel for each of the elements in the
/// collection
/// </summary>
/// <param name="action">Action to perform on each element</param>
public void ForEach(Action<IClientAPI> action)
{
IClientAPI[] localArray = m_array;
Parallel.For(0, localArray.Length,
delegate(int i)
{ action(localArray[i]); }
);
}
/// <summary> /// <summary>
/// Performs a given task synchronously for each of the elements in /// Performs a given task synchronously for each of the elements in
/// the collection /// the collection
/// </summary> /// </summary>
/// <param name="action">Action to perform on each element</param> /// <param name="action">Action to perform on each element</param>
public void ForEachSync(Action<IClientAPI> action) public void ForEach(Action<IClientAPI> action)
{ {
IClientAPI[] localArray = m_array; IClientAPI[] localArray = m_array;
for (int i = 0; i < localArray.Length; i++) for (int i = 0; i < localArray.Length; i++)