public ThreadPoolExecutor(ThreadPoolExecutorOptions options) { this.options = options ?? throw new ArgumentNullException(nameof(options)); workQueue = new ThreadPoolWorkQueue(); statistic = new ThreadPoolTrackingStatistic(options.Name, options.LoggerFactory); 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 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; this.workQueue = new ThreadPoolWorkQueue(); this.statistic = new ThreadPoolTrackingStatistic(options.Name, options.LoggerFactory, statisticsOptions, schedulerStageStatistics); this.log = options.LoggerFactory.CreateLogger <ThreadPoolExecutor>(); this.executingWorkTracker = new ExecutingWorkItemsTracker(options, this.log); options.CancellationTokenSource.Token.Register(Complete); for (var threadIndex = 0; threadIndex < options.DegreeOfParallelism; threadIndex++) { RunWorker(threadIndex); } }
public FastRandom random = new FastRandom(Thread.CurrentThread.ManagedThreadId); // mutable struct, do not copy or make readonly public ThreadPoolWorkQueueThreadLocals(ThreadPoolWorkQueue tpq) { workQueue = tpq; workStealingQueue = new ThreadPoolWorkQueue.WorkStealingQueue(); workQueue.workStealingQueues.Add(workStealingQueue); }