aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorMelanie2009-10-22 07:02:21 +0100
committerMelanie2009-10-22 07:02:21 +0100
commitb35fbe1f98532196befa8bc38deb0aba83d08f6f (patch)
tree2aa3d6c6e8683dcce52709931c998b7e2bf1d42d /OpenSim/Framework
parent* Changed the misc. methods calling ThreadPool.UnsafeQueueUserWorkItem() to U... (diff)
parentMake the LSL scripting delays take full effect. To tune, tweat the (diff)
downloadopensim-SC-b35fbe1f98532196befa8bc38deb0aba83d08f6f.zip
opensim-SC-b35fbe1f98532196befa8bc38deb0aba83d08f6f.tar.gz
opensim-SC-b35fbe1f98532196befa8bc38deb0aba83d08f6f.tar.bz2
opensim-SC-b35fbe1f98532196befa8bc38deb0aba83d08f6f.tar.xz
Merge branch 'melanie_test' into prioritization
This makes SmartThreadPool configurable and also makes it the default, since the regular thread pool simply stinks.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/VersionInfo.cs2
-rw-r--r--OpenSim/Framework/Util.cs26
2 files changed, 24 insertions, 4 deletions
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 9f98310..812abd1 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,7 +29,7 @@ namespace OpenSim
29{ 29{
30 public class VersionInfo 30 public class VersionInfo
31 { 31 {
32 private const string VERSION_NUMBER = "0.6.8"; 32 private const string VERSION_NUMBER = "0.6.8-mel_t";
33 private const Flavour VERSION_FLAVOUR = Flavour.Dev; 33 private const Flavour VERSION_FLAVOUR = Flavour.Dev;
34 34
35 public enum Flavour 35 public enum Flavour
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 02f6d12..d09bd6d 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -41,12 +41,14 @@ using System.Security.Cryptography;
41using System.Text; 41using System.Text;
42using System.Text.RegularExpressions; 42using System.Text.RegularExpressions;
43using System.Xml; 43using System.Xml;
44using System.Threading;
44using log4net; 45using log4net;
45using Nini.Config; 46using Nini.Config;
46using Nwc.XmlRpc; 47using Nwc.XmlRpc;
47using BclExtras; 48using BclExtras;
48using OpenMetaverse; 49using OpenMetaverse;
49using OpenMetaverse.StructuredData; 50using OpenMetaverse.StructuredData;
51using Amib.Threading;
50 52
51namespace OpenSim.Framework 53namespace OpenSim.Framework
52{ 54{
@@ -67,6 +69,8 @@ namespace OpenSim.Framework
67 /// </summary> 69 /// </summary>
68 public class Util 70 public class Util
69 { 71 {
72 private static SmartThreadPool m_ThreadPool = null;
73
70 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 74 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
71 75
72 private static uint nextXferID = 5000; 76 private static uint nextXferID = 5000;
@@ -83,7 +87,7 @@ namespace OpenSim.Framework
83 public static readonly Regex UUIDPattern 87 public static readonly Regex UUIDPattern
84 = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"); 88 = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
85 89
86 public static FireAndForgetMethod FireAndForgetMethod = FireAndForgetMethod.UnsafeQueueUserWorkItem; 90 public static FireAndForgetMethod FireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
87 91
88 /// <summary> 92 /// <summary>
89 /// Linear interpolates B<->C using percent A 93 /// Linear interpolates B<->C using percent A
@@ -1315,6 +1319,23 @@ namespace OpenSim.Framework
1315 FireAndForget(callback, null); 1319 FireAndForget(callback, null);
1316 } 1320 }
1317 1321
1322 public static void SetMaxThreads(int maxThreads)
1323 {
1324 if (m_ThreadPool != null)
1325 return;
1326
1327 STPStartInfo startInfo = new STPStartInfo();
1328 startInfo.IdleTimeout = 2000; // 2 seconds
1329 startInfo.MaxWorkerThreads = maxThreads;
1330 startInfo.MinWorkerThreads = 2;
1331 startInfo.StackSize = 524288;
1332 startInfo.ThreadPriority = ThreadPriority.Normal;
1333
1334 startInfo.StartSuspended = false;
1335
1336 m_ThreadPool = new SmartThreadPool(startInfo);
1337 }
1338
1318 public static void FireAndForget(System.Threading.WaitCallback callback, object obj) 1339 public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
1319 { 1340 {
1320 switch (FireAndForgetMethod) 1341 switch (FireAndForgetMethod)
@@ -1330,8 +1351,7 @@ namespace OpenSim.Framework
1330 wrapper.FireAndForget(callback, obj); 1351 wrapper.FireAndForget(callback, obj);
1331 break; 1352 break;
1332 case FireAndForgetMethod.SmartThreadPool: 1353 case FireAndForgetMethod.SmartThreadPool:
1333 Amib.Threading.SmartThreadPool stp = Singleton.GetInstance<Amib.Threading.SmartThreadPool>(); 1354 m_ThreadPool.QueueWorkItem(delegate(object o) { callback(o); return null; }, obj);
1334 stp.QueueWorkItem(delegate(object o) { callback(o); return null; }, obj);
1335 break; 1355 break;
1336 case FireAndForgetMethod.Thread: 1356 case FireAndForgetMethod.Thread:
1337 System.Threading.Thread thread = new System.Threading.Thread(delegate(object o) { callback(o); }); 1357 System.Threading.Thread thread = new System.Threading.Thread(delegate(object o) { callback(o); });