d588620e70bf15da29cc242e4ae8d86977e8f36a from master; fix hang if you cancel a paused...
[dcpomatic.git] / src / lib / job.h
index 489464558764bc348d85f741f0ddd634ddbdb9b0..8fe87747c2186a465b48799ab8b4734bc9a58fe6 100644 (file)
 #ifndef DCPOMATIC_JOB_H
 #define DCPOMATIC_JOB_H
 
-#include <string>
+#include "signaller.h"
 #include <boost/thread/mutex.hpp>
 #include <boost/enable_shared_from_this.hpp>
 #include <boost/signals2.hpp>
 #include <boost/thread.hpp>
+#include <string>
 
 class Film;
 
 /** @class Job
  *  @brief A parent class to represent long-running tasks which are run in their own thread.
  */
-class Job : public boost::enable_shared_from_this<Job>, public boost::noncopyable
+class Job : public boost::enable_shared_from_this<Job>, public Signaller, public boost::noncopyable
 {
 public:
        Job (boost::shared_ptr<const Film>);
@@ -73,9 +74,10 @@ public:
        void set_progress_unknown ();
        void set_progress (float, bool force = false);
        void sub (std::string);
-       float progress () const;
-       bool progress_unknown () const {
-               return !_progress;
+       boost::optional<float> progress () const;
+
+       boost::shared_ptr<const Film> film () const {
+               return _film;
        }
 
        boost::signals2::signal<void()> Progress;
@@ -123,6 +125,11 @@ private:
        mutable boost::mutex _progress_mutex;
        boost::optional<float> _progress;
 
+       /** condition to signal changes to pause/resume so that we know when to wake;
+           this could be a general _state_change if it made more sense.
+       */
+       boost::condition_variable _pause_changed;
+
        int _ran_for;
 };