Commit a285a45b authored by justcoding121's avatar justcoding121

Merge branch 'master' into beta

parents b138175c 8e63ef94
...@@ -1291,7 +1291,7 @@ Defaults via any IP addresses of this machine.</p> ...@@ -1291,7 +1291,7 @@ Defaults via any IP addresses of this machine.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_ProxyServer_Dispose.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.ProxyServer.Dispose%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a> <a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_ProxyServer_Dispose.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.ProxyServer.Dispose%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span> </span>
<span class="small pull-right mobile-hide"> <span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/ProxyServer.cs/#L890">View Source</a> <a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/ProxyServer.cs/#L895">View Source</a>
</span> </span>
<a id="Titanium_Web_Proxy_ProxyServer_Dispose_" data-uid="Titanium.Web.Proxy.ProxyServer.Dispose*"></a> <a id="Titanium_Web_Proxy_ProxyServer_Dispose_" data-uid="Titanium.Web.Proxy.ProxyServer.Dispose*"></a>
<h4 id="Titanium_Web_Proxy_ProxyServer_Dispose" data-uid="Titanium.Web.Proxy.ProxyServer.Dispose">Dispose()</h4> <h4 id="Titanium_Web_Proxy_ProxyServer_Dispose" data-uid="Titanium.Web.Proxy.ProxyServer.Dispose">Dispose()</h4>
......
...@@ -752,20 +752,32 @@ namespace Titanium.Web.Proxy ...@@ -752,20 +752,32 @@ namespace Titanium.Web.Proxy
endPoint.Listener.BeginAcceptTcpClient(onAcceptConnection, endPoint); endPoint.Listener.BeginAcceptTcpClient(onAcceptConnection, endPoint);
} }
private Lazy<int> maxWorkerThreads = new Lazy<int>(() =>
{
int maxWorkerThreads;
ThreadPool.GetMaxThreads(out maxWorkerThreads, out var _);
return maxWorkerThreads;
});
/// <summary> /// <summary>
/// Change the ThreadPool.WorkerThread minThread /// Change the ThreadPool.WorkerThread minThread
/// </summary> /// </summary>
/// <param name="piNbWorkerThreadsToAdd">Number of threads to add</param> /// <param name="workerThreadsToAdd">Number of threads to add</param>
private void setThreadPoolMinThread(int piNbWorkerThreadsToAdd) private void setThreadPoolMinThread(int workerThreadsToAdd)
{ {
if (EnableThreadPoolOptimizing) if (EnableThreadPoolOptimizing)
{ {
lock (lockThreadPoolTuning) lock (lockThreadPoolTuning)
{ {
int iWorkerThreads, iCompletionPortThreads; int minWorkerThreads, minCompletionPortThreads;
ThreadPool.GetMinThreads(out iWorkerThreads, out iCompletionPortThreads);
iWorkerThreads = Math.Max(iWorkerThreads + piNbWorkerThreadsToAdd, Environment.ProcessorCount); ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);
ThreadPool.SetMinThreads(iWorkerThreads, iCompletionPortThreads); minWorkerThreads = Math.Max(minWorkerThreads + workerThreadsToAdd, Environment.ProcessorCount);
if (minWorkerThreads <= maxWorkerThreads.Value)
{
ThreadPool.SetMinThreads(minWorkerThreads, minCompletionPortThreads);
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment