diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-29 16:33:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-29 16:33:50 +0100 |
| commit | f80d8d37323394113d6491e1cae271e32b2de5b4 (patch) | |
| tree | 47092130d640cbaba3bc773b323f55c3fadb64d5 /src/lib | |
| parent | bd4c3ae31019b2c6217f269a7623f6c2279067c1 (diff) | |
Increase frequency of progres updates on long jobs (#900).
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/job.cc | 16 | ||||
| -rw-r--r-- | src/lib/job.h | 3 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/lib/job.cc b/src/lib/job.cc index ba91debb7..0699c532c 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -270,9 +270,19 @@ Job::elapsed_time () const void Job::set_progress (float p, bool force) { - if (!force && fabs (p - progress().get_value_or(0)) < 0.01) { - /* Calm excessive progress reporting */ - return; + if (!force) { + /* Check for excessively frequent progress reporting */ + boost::mutex::scoped_lock lm (_progress_mutex); + struct timeval now; + gettimeofday (&now, 0); + if (_last_progress_update && _last_progress_update->tv_sec > 0) { + double const elapsed = (now.tv_sec + now.tv_usec / 1000000.0) + - (_last_progress_update->tv_sec + _last_progress_update->tv_usec / 1000000.0); + if (elapsed < 0.5) { + return; + } + } + _last_progress_update = now; } set_progress_common (p); diff --git a/src/lib/job.h b/src/lib/job.h index a6777bc44..7bc051142 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -125,9 +125,10 @@ private: time_t _start_time; std::string _sub_name; - /** mutex for _progress */ + /** mutex for _progress and _last_progress_update */ mutable boost::mutex _progress_mutex; boost::optional<float> _progress; + boost::optional<struct timeval> _last_progress_update; /** 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. |
