Tidy up thread in destructor (Job)
authorCarl Hetherington <cth@carlh.net>
Tue, 1 Sep 2015 20:04:15 +0000 (21:04 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 1 Sep 2015 20:04:15 +0000 (21:04 +0100)
src/lib/job.cc
src/lib/job.h

index 87e4fb3d370c783a99802eaf8dcc09e5e3a2af1c..784defc91736074e53292fdbcdb4c306341d7d6f 100644 (file)
@@ -53,6 +53,16 @@ Job::Job (shared_ptr<const Film> film)
 
 }
 
+Job::~Job ()
+{
+       if (_thread) {
+               _thread->interrupt ();
+               _thread->join ();
+       }
+
+       delete _thread;
+}
+
 /** Start the job in a separate thread, returning immediately */
 void
 Job::start ()
index 4e52e76a1cf6d845741f502882e0792ca5c43ec2..1caa5a90458368e4cdd0d6af696044966efeed93 100644 (file)
@@ -40,7 +40,7 @@ class Job : public boost::enable_shared_from_this<Job>, public Signaller, public
 {
 public:
        Job (boost::shared_ptr<const Film>);
-       virtual ~Job() {}
+       virtual ~Job ();
 
        /** @return user-readable name of this job */
        virtual std::string name () const = 0;