Пример #1
0
        /// <summary>
        /// Returns the state of each job as a string.
        /// This is used by BenchmarkSystem.Status()
        /// </summary>
        /// <returns>String</returns>
        public override string ToString()
        {
            StringBuilder str = new StringBuilder();

            foreach (JobType type in JobType.getTypes())
            {
                str.AppendLine(type + ": " + DatabaseFunctions.GetJobs(type, Job.JobState.Queued).Count() + " jobs");

                /*foreach (Job job in DatabaseFunctions.GetJobs(type, Job.JobState.Queued)) {
                 * str.AppendLine(job.ToString());
                 * }*/
            }
            return(str.ToString());
        }
Пример #2
0
        /// <summary>
        /// Get the next job from the internal queues.
        /// </summary>
        /// <returns></returns>
        public Job PopJob()
        {
            IList <Job> jobs = DatabaseFunctions.GetJobs(Job.JobState.Queued);

            if (jobs.Count() <= 0)
            {
                return(null);
            }
            Job JobToRun = null;
            int pos      = 0;

            while (JobToRun == null)
            {
                uint maxCPU = BenchmarkSystem.instance.CPU - BenchmarkSystem.instance.CPUInUse;
                if (pos >= jobs.Count())
                {
                    pos = 0;
                }
                if (BenchmarkSystem.instance.running[GetJobType(jobs[pos])] < 20)
                {
                    if (jobs[pos].CPU < maxCPU)
                    {
                        JobToRun = jobs[pos];
                    }
                    else
                    {
                        if (jobs[pos].delay())
                        {
                            pos++;
                        }
                        else
                        {
                            Thread.Sleep(200);
                        }
                    }
                }
                else
                {
                    pos++;
                }
            }
            return(JobToRun);
        }
Пример #3
0
 /// <summary>
 /// Returns whether the queues holds the job
 /// </summary>
 /// <param name="job">Job</param>
 /// <returns>bool contains job</returns>
 public bool Contains(Job job)
 {
     return(DatabaseFunctions.JobExists(job, Job.JobState.Queued));
 }
Пример #4
0
 /// <summary>
 /// Return total number of jobs on the queues.
 /// </summary>
 /// <returns>uint total number of jobs</returns>
 public uint TotalNumberOfJobs()
 {
     return((uint)DatabaseFunctions.GetJobs(Job.JobState.Queued).Count());
 }