internal int RegisterWorkItemGroup(string workItemGroupName, ISchedulingContext context, Func <string> statusGetter) { lock (lockable) { int i = workItemGroupCounter; workItemGroupCounter++; if (i == turnsExecutedPerWorkItemGroup.Length) { // need to resize the array Array.Resize(ref turnsExecutedPerWorkItemGroup, 2 * turnsExecutedPerWorkItemGroup.Length); Array.Resize(ref workItemGroupStatuses, 2 * workItemGroupStatuses.Length); } CounterStorage storage = ReportPerWorkItemStats(context) ? CounterStorage.LogAndTable : CounterStorage.DontStore; turnsExecutedPerWorkItemGroup[i] = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.SCHEDULER_ACTIVATION_TURNSEXECUTED_PERACTIVATION, workItemGroupName), storage); workItemGroupStatuses[i] = StringValueStatistic.FindOrCreate(new StatisticName(StatisticNames.SCHEDULER_ACTIVATION_STATUS_PERACTIVATION, workItemGroupName), statusGetter, storage); return(i); } bool ReportPerWorkItemStats(ISchedulingContext schedulingContext) { return(SchedulingUtils.IsSystemPriorityContext(schedulingContext) ? this.collectionLevel >= StatisticsLevel.Verbose2 : this.collectionLevel >= StatisticsLevel.Verbose3); } }
internal static bool ReportPerWorkItemStats(ISchedulingContext schedulingContext) { return(SchedulingUtils.IsSystemContext(schedulingContext) ? IsVerbose2 : IsVerbose3); }