Example #1
0
        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);
            }
        }
Example #2
0
 public Builder(
     string name,
     Type stageType,
     CancellationTokenSource cts,
     ILoggerFactory loggerFactory)
 {
     Options = new ThreadPoolExecutorOptions(name, stageType, cts, loggerFactory);
 }
Example #3
0
 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));
 }