From c74e0e2d9b43b2090782c420f4af709b40d6ba3a Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 15 May 2017 18:10:08 +0100
Subject: 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.
---
OpenSim/Framework/ClientManager.cs | 48 +++++++-------------------------------
1 file changed, 9 insertions(+), 39 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs
index baff2f4..45c54e4 100644
--- a/OpenSim/Framework/ClientManager.cs
+++ b/OpenSim/Framework/ClientManager.cs
@@ -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;
}
@@ -197,25 +181,11 @@ namespace OpenSim.Framework
}
///
- /// Performs a given task in parallel for each of the elements in the
- /// collection
- ///
- /// Action to perform on each element
- public void ForEach(Action action)
- {
- IClientAPI[] localArray = m_array;
- Parallel.For(0, localArray.Length,
- delegate(int i)
- { action(localArray[i]); }
- );
- }
-
- ///
/// Performs a given task synchronously for each of the elements in
/// the collection
///
/// Action to perform on each element
- public void ForEachSync(Action action)
+ public void ForEach(Action action)
{
IClientAPI[] localArray = m_array;
for (int i = 0; i < localArray.Length; i++)
--
cgit v1.1