/// <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()); }
/// <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); }
/// <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)); }
/// <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()); }