mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
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.
This commit is contained in:
@@ -27,10 +27,8 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Net;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
@@ -76,20 +74,16 @@ namespace OpenSim.Framework
|
||||
{
|
||||
lock (m_syncRoot)
|
||||
{
|
||||
if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint))
|
||||
return false;
|
||||
// allow self healing
|
||||
// if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint))
|
||||
// return false;
|
||||
|
||||
m_dict1[value.AgentId] = value;
|
||||
m_dict2[value.RemoteEndPoint] = value;
|
||||
|
||||
IClientAPI[] oldArray = m_array;
|
||||
int oldLength = oldArray.Length;
|
||||
|
||||
IClientAPI[] newArray = new IClientAPI[oldLength + 1];
|
||||
for (int i = 0; i < oldLength; i++)
|
||||
newArray[i] = oldArray[i];
|
||||
newArray[oldLength] = value;
|
||||
|
||||
// dict1 is the master
|
||||
IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
|
||||
m_dict1.Values.CopyTo(newArray, 0);
|
||||
m_array = newArray;
|
||||
}
|
||||
|
||||
@@ -112,22 +106,12 @@ namespace OpenSim.Framework
|
||||
m_dict1.Remove(key);
|
||||
m_dict2.Remove(value.RemoteEndPoint);
|
||||
|
||||
IClientAPI[] oldArray = m_array;
|
||||
int oldLength = oldArray.Length;
|
||||
|
||||
IClientAPI[] newArray = new IClientAPI[oldLength - 1];
|
||||
int j = 0;
|
||||
for (int i = 0; i < oldLength; i++)
|
||||
{
|
||||
if (oldArray[i] != value)
|
||||
newArray[j++] = oldArray[i];
|
||||
}
|
||||
|
||||
IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
|
||||
m_dict1.Values.CopyTo(newArray, 0);
|
||||
m_array = newArray;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
/// Performs a given task synchronously for each of the elements in
|
||||
/// the collection
|
||||
/// </summary>
|
||||
/// <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;
|
||||
for (int i = 0; i < localArray.Length; i++)
|
||||
|
||||
Reference in New Issue
Block a user