diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Util.cs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 167e34d..a18a827 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1324,18 +1324,10 @@ namespace OpenSim.Framework | |||
1324 | { | 1324 | { |
1325 | if (maxThreads < 2) | 1325 | if (maxThreads < 2) |
1326 | throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2"); | 1326 | throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2"); |
1327 | |||
1328 | if (m_ThreadPool != null) | 1327 | if (m_ThreadPool != null) |
1329 | return; | 1328 | throw new InvalidOperationException("SmartThreadPool is already initialized"); |
1330 | |||
1331 | STPStartInfo startInfo = new STPStartInfo(); | ||
1332 | startInfo.IdleTimeout = 2000; // 2 seconds | ||
1333 | startInfo.MaxWorkerThreads = maxThreads; | ||
1334 | startInfo.MinWorkerThreads = 2; | ||
1335 | startInfo.ThreadPriority = ThreadPriority.Normal; | ||
1336 | startInfo.StartSuspended = false; | ||
1337 | 1329 | ||
1338 | m_ThreadPool = new SmartThreadPool(startInfo); | 1330 | m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2); |
1339 | } | 1331 | } |
1340 | 1332 | ||
1341 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj) | 1333 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj) |
@@ -1343,20 +1335,22 @@ namespace OpenSim.Framework | |||
1343 | switch (FireAndForgetMethod) | 1335 | switch (FireAndForgetMethod) |
1344 | { | 1336 | { |
1345 | case FireAndForgetMethod.UnsafeQueueUserWorkItem: | 1337 | case FireAndForgetMethod.UnsafeQueueUserWorkItem: |
1346 | System.Threading.ThreadPool.UnsafeQueueUserWorkItem(callback, obj); | 1338 | ThreadPool.UnsafeQueueUserWorkItem(callback, obj); |
1347 | break; | 1339 | break; |
1348 | case FireAndForgetMethod.QueueUserWorkItem: | 1340 | case FireAndForgetMethod.QueueUserWorkItem: |
1349 | System.Threading.ThreadPool.QueueUserWorkItem(callback, obj); | 1341 | ThreadPool.QueueUserWorkItem(callback, obj); |
1350 | break; | 1342 | break; |
1351 | case FireAndForgetMethod.BeginInvoke: | 1343 | case FireAndForgetMethod.BeginInvoke: |
1352 | FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>(); | 1344 | FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>(); |
1353 | wrapper.FireAndForget(callback, obj); | 1345 | wrapper.FireAndForget(callback, obj); |
1354 | break; | 1346 | break; |
1355 | case FireAndForgetMethod.SmartThreadPool: | 1347 | case FireAndForgetMethod.SmartThreadPool: |
1348 | if (m_ThreadPool != null) | ||
1349 | m_ThreadPool = new SmartThreadPool(2000, 15, 2); | ||
1356 | m_ThreadPool.QueueWorkItem(delegate(object o) { callback(o); return null; }, obj); | 1350 | m_ThreadPool.QueueWorkItem(delegate(object o) { callback(o); return null; }, obj); |
1357 | break; | 1351 | break; |
1358 | case FireAndForgetMethod.Thread: | 1352 | case FireAndForgetMethod.Thread: |
1359 | System.Threading.Thread thread = new System.Threading.Thread(delegate(object o) { callback(o); }); | 1353 | Thread thread = new Thread(delegate(object o) { callback(o); }); |
1360 | thread.Start(obj); | 1354 | thread.Start(obj); |
1361 | break; | 1355 | break; |
1362 | default: | 1356 | default: |