projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge master.
[dcpomatic.git]
/
src
/
lib
/
job_manager.cc
diff --git
a/src/lib/job_manager.cc
b/src/lib/job_manager.cc
index 76fcc6c5d736d72a25b3079584706bb4b6b8963d..9105976280dd3b7d5ab58f81a362bdb72dcf5a9d 100644
(file)
--- a/
src/lib/job_manager.cc
+++ b/
src/lib/job_manager.cc
@@
-26,22
+26,26
@@
#include "job_manager.h"
#include "job.h"
#include "cross.h"
#include "job_manager.h"
#include "job.h"
#include "cross.h"
+#include "ui_signaller.h"
-using namespace std;
-using namespace boost;
+using std::string;
+using std::list;
+using boost::shared_ptr;
JobManager* JobManager::_instance = 0;
JobManager::JobManager ()
JobManager* JobManager::_instance = 0;
JobManager::JobManager ()
+ : _last_active_jobs (false)
{
boost::thread (boost::bind (&JobManager::scheduler, this));
}
{
boost::thread (boost::bind (&JobManager::scheduler, this));
}
-void
+shared_ptr<Job>
JobManager::add (shared_ptr<Job> j)
{
boost::mutex::scoped_lock lm (_mutex);
_jobs.push_back (j);
JobManager::add (shared_ptr<Job> j)
{
boost::mutex::scoped_lock lm (_mutex);
_jobs.push_back (j);
+ return j;
}
void
}
void
@@
-86,29
+90,42
@@
JobManager::errors () const
return false;
}
return false;
}
-
void
JobManager::scheduler ()
{
while (1) {
void
JobManager::scheduler ()
{
while (1) {
+
+ bool active_jobs = false;
+
{
boost::mutex::scoped_lock lm (_mutex);
{
boost::mutex::scoped_lock lm (_mutex);
- int running = 0;
- shared_ptr<Job> first_new;
for (list<shared_ptr<Job> >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) {
for (list<shared_ptr<Job> >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) {
+
+ if (!(*i)->finished ()) {
+ active_jobs = true;
+ }
+
if ((*i)->running ()) {
if ((*i)->running ()) {
- ++running;
- } else if (!(*i)->finished () && first_new == 0) {
- first_new = *i;
+ /* Something is already happening */
+ break;
}
}
-
- if (running == 0 && first_new) {
- first_new->start ();
+
+ if ((*i)->is_new()) {
+ (*i)->start ();
+
+ /* Only start one job at once */
break;
}
}
}
break;
}
}
}
+ if (active_jobs != _last_active_jobs) {
+ _last_active_jobs = active_jobs;
+ if (ui_signaller) {
+ ui_signaller->emit (boost::bind (boost::ref (ActiveJobsChanged), active_jobs));
+ }
+ }
+
dvdomatic_sleep (1);
}
}
dvdomatic_sleep (1);
}
}