2016-06-29 Carl Hetherington <cth@carlh.net>
+ * Increase frequency of progress reporting on long
+ encodes (#900).
+
* Obey specified colour conversion when previewing
RGB and XYZ JPEG2000 files.
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);
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.