Note that newer libsub version is required.
[dcpomatic.git] / src / lib / job.h
index 8edde68453bea67148af71e6fa28fb4dd168665b..d4d0f95109b6e8936f68f1251d6e2e3c68806f78 100644 (file)
 
 */
 
+
 /** @file src/job.h
  *  @brief A parent class to represent long-running tasks which are run in their own thread.
  */
 
+
 #ifndef DCPOMATIC_JOB_H
 #define DCPOMATIC_JOB_H
 
+
 #include "signaller.h"
-#include <boost/thread/mutex.hpp>
+#include <boost/atomic.hpp>
 #include <boost/signals2.hpp>
 #include <boost/thread.hpp>
+#include <boost/thread/mutex.hpp>
 #include <string>
 
+
 class Film;
 
+
 /** @class Job
  *  @brief A parent class to represent long-running tasks which are run in their own thread.
  */
@@ -99,6 +105,8 @@ public:
 
        void when_finished(boost::signals2::connection& connection, std::function<void(Result)> finished);
 
+       void set_rate_limit_progress(bool rate_limit);
+
        boost::signals2::signal<void()> Progress;
        /** Emitted from the UI thread when the job is finished */
        boost::signals2::signal<void (Result)> Finished;
@@ -130,6 +138,9 @@ protected:
 
        std::shared_ptr<const Film> _film;
 
+       time_t _start_time = 0;
+       time_t _finish_time = 0;
+
 private:
 
        void run_wrapper ();
@@ -147,18 +158,20 @@ private:
        /** a message that should be given to the user when the job finishes */
        boost::optional<std::string> _message;
 
-       /** time that this job was started */
-       time_t _start_time;
        /** time that this sub-job was started */
        time_t _sub_start_time;
        std::string _sub_name;
-       time_t _finish_time = 0;
 
        /** mutex for _progress and _last_progress_update */
        mutable boost::mutex _progress_mutex;
        boost::optional<float> _progress;
        boost::optional<struct timeval> _last_progress_update;
 
+       /** true to limit emissions of the progress signal so that they don't
+        *  come too often.
+        */
+       boost::atomic<bool> _rate_limit_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.
        */