aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorUbitUmarov2017-05-15 18:10:08 +0100
committerUbitUmarov2017-05-15 18:10:08 +0100
commitc74e0e2d9b43b2090782c420f4af709b40d6ba3a (patch)
tree59cfb1f5bcd69c28ee706bcabbc190f54ebfeac1 /OpenSim/Framework
parentUpdate NPGSQL from version 2.0.14.3 to 2.1.3. This is a relatively big update... (diff)
downloadopensim-SC-c74e0e2d9b43b2090782c420f4af709b40d6ba3a.zip
opensim-SC-c74e0e2d9b43b2090782c420f4af709b40d6ba3a.tar.gz
opensim-SC-c74e0e2d9b43b2090782c420f4af709b40d6ba3a.tar.bz2
opensim-SC-c74e0e2d9b43b2090782c420f4af709b40d6ba3a.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/ClientManager.cs48
1 files changed, 9 insertions, 39 deletions
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 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection;
31using System.Net; 30using System.Net;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenMetaverse.Packets;
34 32
35namespace OpenSim.Framework 33namespace OpenSim.Framework
36{ 34{
@@ -76,20 +74,16 @@ namespace OpenSim.Framework
76 { 74 {
77 lock (m_syncRoot) 75 lock (m_syncRoot)
78 { 76 {
79 if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint)) 77 // allow self healing
80 return false; 78// if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint))
79// return false;
81 80
82 m_dict1[value.AgentId] = value; 81 m_dict1[value.AgentId] = value;
83 m_dict2[value.RemoteEndPoint] = value; 82 m_dict2[value.RemoteEndPoint] = value;
84 83
85 IClientAPI[] oldArray = m_array; 84 // dict1 is the master
86 int oldLength = oldArray.Length; 85 IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
87 86 m_dict1.Values.CopyTo(newArray, 0);
88 IClientAPI[] newArray = new IClientAPI[oldLength + 1];
89 for (int i = 0; i < oldLength; i++)
90 newArray[i] = oldArray[i];
91 newArray[oldLength] = value;
92
93 m_array = newArray; 87 m_array = newArray;
94 } 88 }
95 89
@@ -112,22 +106,12 @@ namespace OpenSim.Framework
112 m_dict1.Remove(key); 106 m_dict1.Remove(key);
113 m_dict2.Remove(value.RemoteEndPoint); 107 m_dict2.Remove(value.RemoteEndPoint);
114 108
115 IClientAPI[] oldArray = m_array; 109 IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
116 int oldLength = oldArray.Length; 110 m_dict1.Values.CopyTo(newArray, 0);
117
118 IClientAPI[] newArray = new IClientAPI[oldLength - 1];
119 int j = 0;
120 for (int i = 0; i < oldLength; i++)
121 {
122 if (oldArray[i] != value)
123 newArray[j++] = oldArray[i];
124 }
125
126 m_array = newArray; 111 m_array = newArray;
127 return true; 112 return true;
128 } 113 }
129 } 114 }
130
131 return false; 115 return false;
132 } 116 }
133 117
@@ -197,25 +181,11 @@ namespace OpenSim.Framework
197 } 181 }
198 182
199 /// <summary> 183 /// <summary>
200 /// Performs a given task in parallel for each of the elements in the
201 /// collection
202 /// </summary>
203 /// <param name="action">Action to perform on each element</param>
204 public void ForEach(Action<IClientAPI> action)
205 {
206 IClientAPI[] localArray = m_array;
207 Parallel.For(0, localArray.Length,
208 delegate(int i)
209 { action(localArray[i]); }
210 );
211 }
212
213 /// <summary>
214 /// Performs a given task synchronously for each of the elements in 184 /// Performs a given task synchronously for each of the elements in
215 /// the collection 185 /// the collection
216 /// </summary> 186 /// </summary>
217 /// <param name="action">Action to perform on each element</param> 187 /// <param name="action">Action to perform on each element</param>
218 public void ForEachSync(Action<IClientAPI> action) 188 public void ForEach(Action<IClientAPI> action)
219 { 189 {
220 IClientAPI[] localArray = m_array; 190 IClientAPI[] localArray = m_array;
221 for (int i = 0; i < localArray.Length; i++) 191 for (int i = 0; i < localArray.Length; i++)