diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-09 15:14:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-09 15:14:08 +0100 |
| commit | 92cafb6fc686a041354da2eabde6bcb2f6846e1d (patch) | |
| tree | cdc26dde96d8c9ed1e9c60056a404ca3df2dcfac /src/lib | |
| parent | fd040c2bd27fde35424a384174ecb56c643764cd (diff) | |
| parent | 6e5c4e570f26e05124ab0ef67e39c07bab9cb4d5 (diff) | |
Merge master.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/job.cc | 28 | ||||
| -rw-r--r-- | src/lib/job.h | 4 | ||||
| -rw-r--r-- | src/lib/util.cc | 2 | ||||
| -rw-r--r-- | src/lib/util.h | 2 |
4 files changed, 34 insertions, 2 deletions
diff --git a/src/lib/job.cc b/src/lib/job.cc index 812380594..2e6385d62 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -26,6 +26,7 @@ #include <libdcp/exceptions.h> #include "job.h" #include "util.h" +#include "cross.h" #include "i18n.h" @@ -153,6 +154,13 @@ Job::finished_cancelled () const return _state == FINISHED_CANCELLED; } +bool +Job::paused () const +{ + boost::mutex::scoped_lock lm (_state_mutex); + return _state == PAUSED; +} + /** Set the state of this job. * @param s New state. */ @@ -188,6 +196,10 @@ Job::set_progress (float p) _progress_unknown = false; _stack.back().normalised = p; boost::this_thread::interruption_point (); + + if (paused ()) { + dcpomatic_sleep (1); + } } /** @return fractional overall progress, or -1 if not known */ @@ -324,3 +336,19 @@ Job::cancel () _thread->interrupt (); _thread->join (); } + +void +Job::pause () +{ + if (running ()) { + set_state (PAUSED); + } +} + +void +Job::resume () +{ + if (paused ()) { + set_state (RUNNING); + } +} diff --git a/src/lib/job.h b/src/lib/job.h index 2119db2f3..40e90b73c 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -47,6 +47,8 @@ public: virtual void run () = 0; void start (); + void pause (); + void resume (); void cancel (); bool is_new () const; @@ -55,6 +57,7 @@ public: bool finished_ok () const; bool finished_in_error () const; bool finished_cancelled () const; + bool paused () const; std::string error_summary () const; std::string error_details () const; @@ -79,6 +82,7 @@ protected: enum State { NEW, ///< the job hasn't been started yet RUNNING, ///< the job is running + PAUSED, ///< the job has been paused FINISHED_OK, ///< the job has finished successfully FINISHED_ERROR, ///< the job has finished in error FINISHED_CANCELLED ///< the job was cancelled diff --git a/src/lib/util.cc b/src/lib/util.cc index ec1fd47bd..6c8166143 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -280,7 +280,7 @@ mo_path () #endif void -dcpomatic_setup_i18n (string lang) +dcpomatic_setup_gettext_i18n (string lang) { #ifdef DCPOMATIC_POSIX lang += ".UTF8"; diff --git a/src/lib/util.h b/src/lib/util.h index 0edfe2076..51ccbba99 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -56,7 +56,7 @@ extern void stacktrace (std::ostream &, int); extern std::string dependency_version_summary (); extern double seconds (struct timeval); extern void dcpomatic_setup (); -extern void dcpomatic_setup_i18n (std::string); +extern void dcpomatic_setup_gettext_i18n (std::string); extern std::vector<std::string> split_at_spaces_considering_quotes (std::string); extern std::string md5_digest (boost::filesystem::path); extern std::string md5_digest (void const *, int); |
