public ThreadPoolExecutor( ThreadPoolExecutorOptions options, SchedulerStatisticsGroup schedulerStatistics, StageAnalysisStatisticsGroup schedulerStageStatistics, IOptions <StatisticsOptions> statisticsOptions) { this.options = options ?? throw new ArgumentNullException(nameof(options)); this.schedulerStatistics = schedulerStatistics; this.schedulerStageStatistics = schedulerStageStatistics; this.statisticsOptions = statisticsOptions; workQueue = new ThreadPoolWorkQueue(); statistic = new ThreadPoolTrackingStatistic(options.Name, options.LoggerFactory, statisticsOptions, schedulerStageStatistics); executingWorkTracker = new ExecutingWorkItemsTracker(this); log = options.LoggerFactory.CreateLogger <ThreadPoolExecutor>(); options.CancellationTokenSource.Token.Register(Complete); for (var threadIndex = 0; threadIndex < options.DegreeOfParallelism; threadIndex++) { RunWorker(threadIndex); } }
public Builder( string name, Type stageType, CancellationTokenSource cts, ILoggerFactory loggerFactory) { Options = new ThreadPoolExecutorOptions(name, stageType, cts, loggerFactory); }
public ExecutingWorkItemsTracker(ThreadPoolExecutorOptions options, ILogger log) { if (options == null) { throw new ArgumentNullException(nameof(options)); } this.runningItems = new WorkItem[GetThreadSlot(options.DegreeOfParallelism)]; this.log = log ?? throw new ArgumentNullException(nameof(log)); }