支持配置是否设置线程池
This commit is contained in:
@@ -49,7 +49,7 @@ namespace dotnetCampus.ApplicationStartupManager
|
||||
private IStartupLogger Logger => Context.Logger;
|
||||
|
||||
public StartupManager(IStartupLogger logger, FileConfigurationRepo configurationRepo,
|
||||
Func<Exception, Task> fastFailAction, IMainThreadDispatcher dispatcher)
|
||||
Func<Exception, Task> fastFailAction, IMainThreadDispatcher dispatcher, bool shouldSetThreadPool = true)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
@@ -63,12 +63,13 @@ namespace dotnetCampus.ApplicationStartupManager
|
||||
|
||||
_dispatcher = dispatcher;
|
||||
|
||||
ThreadPool.GetMinThreads(out _workerThreads, out _completionPortThreads);
|
||||
//启动期间存在大量的线程池调用(包含IO操作),而创建的多数线程在等待 IO 时都是不会被调度的
|
||||
//设置更多的初始化线程数可以减少启动期间的线程调度等待
|
||||
ThreadPool.SetMinThreads(Math.Max(_workerThreads, 16), Math.Max(_completionPortThreads, 16));
|
||||
|
||||
// release bugfix code
|
||||
if (shouldSetThreadPool)
|
||||
{
|
||||
ThreadPool.GetMinThreads(out _workerThreads, out _completionPortThreads);
|
||||
//启动期间存在大量的线程池调用(包含IO操作),而创建的多数线程在等待 IO 时都是不会被调度的
|
||||
//设置更多的初始化线程数可以减少启动期间的线程调度等待
|
||||
ThreadPool.SetMinThreads(Math.Max(_workerThreads, 16), Math.Max(_completionPortThreads, 16));
|
||||
}
|
||||
|
||||
Context = new StartupContext(logger, configurationRepo,
|
||||
fastFailAction, WaitStartupTaskAsync);
|
||||
|
||||
Reference in New Issue
Block a user