Esempio n. 1
0
        public static SchedulerStats GatherOveralStatistics(IEnumerable<WorkItem> _work)
        {
            var stats = new SchedulerStats();

            stats.CurrentJobs = _work
                .Reverse()
                .Select(x => new SchedulerJobStats
                   {
                        WorkKey = x.WorkKey,
                        Description = x.Description,
                        CurrentStatus = (SchedulerJobStatus)x.Status,
                        LastRunStarted = x.LastStart,
                        LastRunCompleted = x.LastComplete,
                        PreviousRuns = x.PreviousRuns.Select(xx => new SchedulerJobRunStats
                        {
                            Started = xx.Started,
                            Completed = xx.Completed,
                            Result = (SchedulerJobRunResult)xx.Result,
                            ResultMessage = xx.ResultMessage
                        }).ToList()
                    }).ToList();

            stats.PendingJobs = stats.CurrentJobs.Count(x => x.CurrentStatus == SchedulerJobStatus.Pending);
            stats.RunningJobs = stats.CurrentJobs.Count(x => x.CurrentStatus == SchedulerJobStatus.Running);
            stats.ScheduledJobs = stats.CurrentJobs.Count(x => x.CurrentStatus == SchedulerJobStatus.Scheduled);

            return stats;
        }
Esempio n. 2
0
            public Scheduler(IGameContext context)
            {
                _stats = new SchedulerStats(context);

                _queue.Add(Priority.Critical, new SortedSetTimedQueue <Action>());
                _queue.Add(Priority.Routine, new SortedSetTimedQueue <Action>());
                _queue.Add(Priority.Unimportant, new SortedSetTimedQueue <Action>());
            }