Browse Source

smartthreadpool: add pool option SuppressFlow and test it on main smart?? pool (may go bad)

UbitUmarov 3 years ago
parent
commit
960a0fa360

+ 2 - 1
OpenSim/Framework/Util.cs

@@ -2898,7 +2898,8 @@ namespace OpenSim.Framework
                 ThreadPoolName = "Util",
                 IdleTimeout = 20000,
                 MaxWorkerThreads = maxThreads,
-                MinWorkerThreads = minThreads
+                MinWorkerThreads = minThreads,
+                SuppressFlow = true
             };
 
             m_ThreadPool = new SmartThreadPool(startInfo);

+ 12 - 0
ThirdParty/SmartThreadPool/STPStartInfo.cs

@@ -17,6 +17,7 @@ namespace Amib.Threading
         private bool _enableLocalPerformanceCounters;
         private string _threadPoolName = SmartThreadPool.DefaultThreadPoolName;
         private int? _maxStackSize = SmartThreadPool.DefaultMaxStackSize;
+        private bool _supressflow = false;
 
         public STPStartInfo()
         {
@@ -39,6 +40,7 @@ namespace Amib.Threading
             _threadPoolName = stpStartInfo._threadPoolName;
             _areThreadsBackground = stpStartInfo.AreThreadsBackground;
             _apartmentState = stpStartInfo._apartmentState;
+            _supressflow = stpStartInfo._supressflow;
         }
 
         /// <summary>
@@ -191,5 +193,15 @@ namespace Amib.Threading
                 _maxStackSize = value;
             }
         }
+
+        public bool SuppressFlow
+        {
+            get { return _supressflow; }
+            set
+            {
+                ThrowIfReadOnly();
+                _supressflow = value;
+            }
+        }
     }
 }

+ 18 - 6
ThirdParty/SmartThreadPool/SmartThreadPool.cs

@@ -608,12 +608,24 @@ namespace Amib.Threading
                     }
 
                     // Create a new thread
-
-                    Thread workerThread =
-                        _stpStartInfo.MaxStackSize.HasValue
-                        ? new Thread(ProcessQueuedItems, _stpStartInfo.MaxStackSize.Value)
-                        : new Thread(ProcessQueuedItems);
-
+                    Thread workerThread;
+                    if(_stpStartInfo.SuppressFlow)
+                    {
+                        using(ExecutionContext.SuppressFlow())
+                        {
+                            workerThread =
+                                _stpStartInfo.MaxStackSize.HasValue
+                                ? new Thread(ProcessQueuedItems, _stpStartInfo.MaxStackSize.Value)
+                                : new Thread(ProcessQueuedItems);
+                         }
+                    }
+                    else
+                    {
+                        workerThread =
+                                _stpStartInfo.MaxStackSize.HasValue
+                                ? new Thread(ProcessQueuedItems, _stpStartInfo.MaxStackSize.Value)
+                                : new Thread(ProcessQueuedItems);
+                    }
                     // Configure the new thread and start it
                     workerThread.IsBackground = _stpStartInfo.AreThreadsBackground;