X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fjob.h;h=06a341f40d6808581d4bcf44ed3f2805f15285d1;hb=e60bb3e51bd1508b149e6b8f6608f09b5196ae26;hp=6310da32ae69a2b87db7bdbc8cb29688b447a418;hpb=29a3d5d116da0626f71bf488b0408bd461327184;p=dcpomatic.git diff --git a/src/lib/job.h b/src/lib/job.h index 6310da32a..06a341f40 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -24,18 +24,19 @@ #ifndef DCPOMATIC_JOB_H #define DCPOMATIC_JOB_H -#include +#include "signaller.h" #include #include #include #include +#include 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, public boost::noncopyable +class Job : public boost::enable_shared_from_this, public Signaller, public boost::noncopyable { public: Job (boost::shared_ptr); @@ -43,9 +44,10 @@ public: /** @return user-readable name of this job */ virtual std::string name () const = 0; + virtual std::string json_name () const = 0; /** Run this job in the current thread. */ virtual void run () = 0; - + void start (); void pause (); void resume (); @@ -64,6 +66,7 @@ public: int elapsed_time () const; virtual std::string status () const; + std::string json_status () const; std::string sub_name () const { return _sub_name; } @@ -71,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 progress () const; + + boost::shared_ptr film () const { + return _film; } boost::signals2::signal Progress; @@ -93,7 +97,7 @@ protected: FINISHED_ERROR, ///< the job has finished in error FINISHED_CANCELLED ///< the job was cancelled }; - + void set_state (State); void set_error (std::string s, std::string d); @@ -121,6 +125,11 @@ private: mutable boost::mutex _progress_mutex; boost::optional _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; };