JobQueue::RunningJobInfo JobQueue::acquire_scheduled_job() { Spinlock::ScopedLock lock(impl->m_spinlock); // Bail out if there is no scheduled job. if (impl->m_scheduled_jobs.empty()) return RunningJobInfo(JobInfo(0, false), impl->m_running_jobs.end()); // Move the next scheduled job to the end of the queue of running jobs. const JobInfo job_info = impl->m_scheduled_jobs.front(); impl->m_scheduled_jobs.pop_front(); impl->m_running_jobs.push_back(job_info); return RunningJobInfo(job_info, pred(impl->m_running_jobs.end())); }
JobQueue::RunningJobInfo JobQueue::acquire_scheduled_job_unlocked() { // Bail out if there is no scheduled job. if (impl->m_scheduled_jobs.empty()) return RunningJobInfo(JobInfo(0, false), impl->m_running_jobs.end()); // Move the next scheduled job to the end of the queue of running jobs. const JobInfo job_info = impl->m_scheduled_jobs.front(); impl->m_scheduled_jobs.pop_front(); impl->m_running_jobs.push_back(job_info); // Notify worker threads that a job has moved from the scheduled to the running state. impl->m_event.notify_all(); return RunningJobInfo(job_info, pred(impl->m_running_jobs.end())); }