- bool changed = false;
-
- for (list<shared_ptr<Job> >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) {
- list<shared_ptr<Job> >::iterator next = i;
- ++next;
- if (*i == job && next != _jobs.end()) {
- swap (*i, *next);
- changed = true;
- break;
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ auto iter = std::find(_jobs.begin(), _jobs.end(), job);
+ if (iter == _jobs.end() || std::next(iter) == _jobs.end()) {
+ return;
+ }
+ swap(*iter, *std::next(iter));
+ }
+
+ _empty_condition.notify_all();
+ emit(boost::bind(boost::ref(JobsReordered)));
+}
+
+
+void
+JobManager::pause ()
+{
+ boost::mutex::scoped_lock lm (_mutex);
+
+ if (_paused_job) {
+ return;
+ }
+
+ for (auto i: _jobs) {
+ if (i->pause_by_user()) {
+ _paused_job = i;