diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-11-04 23:43:54 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-11-13 22:54:00 +0100 |
| commit | 5723d8d8518ad1cc0fef8bcc34a47671ab959fb3 (patch) | |
| tree | 061648f75d7d74309a42e6324ac6d9e2cc1bf31a /src/lib/job.cc | |
| parent | dd3ddb4359a9f8b7ce08ce92e0315dccc65bf40b (diff) | |
Add Job::seconds_since_last_progress_update().
Diffstat (limited to 'src/lib/job.cc')
| -rw-r--r-- | src/lib/job.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/job.cc b/src/lib/job.cc index cb2120de1..4c8199bdc 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -361,6 +361,22 @@ Job::check_for_interruption_or_pause () } } + +optional<float> +Job::seconds_since_last_progress_update () const +{ + boost::mutex::scoped_lock lm (_progress_mutex); + if (!_last_progress_update) { + return {}; + } + + struct timeval now; + gettimeofday (&now, 0); + + return seconds(now) - seconds(*_last_progress_update); +} + + /** Set the progress of the current part of the job. * @param p Progress (from 0 to 1) * @param force Do not ignore this update, even if it hasn't been long since the last one. |
