diff options
author | John Hurliman | 2009-10-27 14:16:01 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-27 14:16:01 -0700 |
commit | f89c2cac0fd3e9e1ae66552bbc2c3cc4bb17aaed (patch) | |
tree | ff8e7f0ee8892e8c643e2ede4c794173f6dc528b /OpenSim/Framework/Util.cs | |
parent | Updating prebuild.xml to reflect the removal of DotNetEngine (diff) | |
download | opensim-SC_OLD-f89c2cac0fd3e9e1ae66552bbc2c3cc4bb17aaed.zip opensim-SC_OLD-f89c2cac0fd3e9e1ae66552bbc2c3cc4bb17aaed.tar.gz opensim-SC_OLD-f89c2cac0fd3e9e1ae66552bbc2c3cc4bb17aaed.tar.bz2 opensim-SC_OLD-f89c2cac0fd3e9e1ae66552bbc2c3cc4bb17aaed.tar.xz |
Experimental test to rate limit the incoming packet handler and try to always leave a worker thread available for other tasks
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 10f38ab..87ba5a8 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1330,6 +1330,27 @@ namespace OpenSim.Framework | |||
1330 | m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2); | 1330 | m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2); |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | public static int FireAndForgetCount() | ||
1334 | { | ||
1335 | const int MAX_SYSTEM_THREADS = 200; | ||
1336 | |||
1337 | switch (FireAndForgetMethod) | ||
1338 | { | ||
1339 | case FireAndForgetMethod.UnsafeQueueUserWorkItem: | ||
1340 | case FireAndForgetMethod.QueueUserWorkItem: | ||
1341 | case FireAndForgetMethod.BeginInvoke: | ||
1342 | int workerThreads, iocpThreads; | ||
1343 | ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads); | ||
1344 | return workerThreads; | ||
1345 | case FireAndForgetMethod.SmartThreadPool: | ||
1346 | return m_ThreadPool.MaxThreads - m_ThreadPool.InUseThreads; | ||
1347 | case FireAndForgetMethod.Thread: | ||
1348 | return MAX_SYSTEM_THREADS - System.Diagnostics.Process.GetCurrentProcess().Threads.Count; | ||
1349 | default: | ||
1350 | throw new NotImplementedException(); | ||
1351 | } | ||
1352 | } | ||
1353 | |||
1333 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj) | 1354 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj) |
1334 | { | 1355 | { |
1335 | switch (FireAndForgetMethod) | 1356 | switch (FireAndForgetMethod) |