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>
<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 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>
<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>
......
......@@ -752,20 +752,32 @@ namespace Titanium.Web.Proxy
endPoint.Listener.BeginAcceptTcpClient(onAcceptConnection, endPoint);
}
private Lazy<int> maxWorkerThreads = new Lazy<int>(() =>
{
int maxWorkerThreads;
ThreadPool.GetMaxThreads(out maxWorkerThreads, out var _);
return maxWorkerThreads;
});
/// <summary>
/// Change the ThreadPool.WorkerThread minThread
/// </summary>
/// <param name="piNbWorkerThreadsToAdd">Number of threads to add</param>
private void setThreadPoolMinThread(int piNbWorkerThreadsToAdd)
/// <param name="workerThreadsToAdd">Number of threads to add</param>
private void setThreadPoolMinThread(int workerThreadsToAdd)
{
if (EnableThreadPoolOptimizing)
{
lock (lockThreadPoolTuning)
{
int iWorkerThreads, iCompletionPortThreads;
ThreadPool.GetMinThreads(out iWorkerThreads, out iCompletionPortThreads);
iWorkerThreads = Math.Max(iWorkerThreads + piNbWorkerThreadsToAdd, Environment.ProcessorCount);
ThreadPool.SetMinThreads(iWorkerThreads, iCompletionPortThreads);
int minWorkerThreads, minCompletionPortThreads;
ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);
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