- BOOST_FOREACH (shared_ptr<Job> i, _jobs) {
- if (i->is_new()) {
- _connections.push_back (i->FinishedImmediate.connect(bind(&JobManager::job_finished, this)));
- i->start ();
+ bool have_running = false;
+ for (auto i: _jobs) {
+ if ((have_running || _paused) && i->running()) {
+ /* We already have a running job, or are totally paused, so this job should not be running */
+ i->pause_by_priority();
+ } else if (!have_running && !_paused && (i->is_new() || i->paused_by_priority())) {
+ /* We don't have a running job, and we should have one, so start/resume this */
+ if (i->is_new()) {
+ _connections.push_back (i->FinishedImmediate.connect(bind(&JobManager::job_finished, this)));
+ i->start ();
+ } else {
+ i->resume ();
+ }