projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove a couple of uses of ofstream.
[dcpomatic.git]
/
src
/
lib
/
job_manager.cc
diff --git
a/src/lib/job_manager.cc
b/src/lib/job_manager.cc
index 2d216dacb947e58c45b3fd6391858d59f9869dae..056b9f925e1b237946122d804241614bb87f416c 100644
(file)
--- a/
src/lib/job_manager.cc
+++ b/
src/lib/job_manager.cc
@@
-30,21
+30,44
@@
using std::string;
using std::list;
using std::string;
using std::list;
+using std::cout;
using boost::shared_ptr;
using boost::shared_ptr;
+using boost::weak_ptr;
JobManager* JobManager::_instance = 0;
JobManager::JobManager ()
JobManager* JobManager::_instance = 0;
JobManager::JobManager ()
- : _last_active_jobs (false)
+ : _terminate (false)
+ , _last_active_jobs (false)
+ , _scheduler (new boost::thread (boost::bind (&JobManager::scheduler, this)))
{
{
- boost::thread (boost::bind (&JobManager::scheduler, this));
+
+}
+
+JobManager::~JobManager ()
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _terminate = true;
+ }
+
+ if (_scheduler->joinable ()) {
+ _scheduler->join ();
+ }
}
shared_ptr<Job>
JobManager::add (shared_ptr<Job> j)
{
}
shared_ptr<Job>
JobManager::add (shared_ptr<Job> j)
{
- boost::mutex::scoped_lock lm (_mutex);
- _jobs.push_back (j);
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _jobs.push_back (j);
+ }
+
+ if (ui_signaller) {
+ ui_signaller->emit (boost::bind (boost::ref (JobAdded), weak_ptr<Job> (j)));
+ }
+
return j;
}
return j;
}
@@
-89,6
+112,10
@@
JobManager::scheduler ()
{
boost::mutex::scoped_lock lm (_mutex);
{
boost::mutex::scoped_lock lm (_mutex);
+ if (_terminate) {
+ return;
+ }
+
for (list<shared_ptr<Job> >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) {
if (!(*i)->finished ()) {
for (list<shared_ptr<Job> >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) {
if (!(*i)->finished ()) {
@@
-129,3
+156,10
@@
JobManager::instance ()
return _instance;
}
return _instance;
}
+
+void
+JobManager::drop ()
+{
+ delete _instance;
+ _instance = 0;
+}