From a2002bc983fb2ed3c767f2bc81db4e0da069ca82 Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 19 Jan 2022 01:07:17 +0100 Subject: [PATCH] Support frequency of ProgressReporter calls lower than interval --- components/misc/progressreporter.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/misc/progressreporter.hpp b/components/misc/progressreporter.hpp index 733e36191e..30d9b0ae2e 100644 --- a/components/misc/progressreporter.hpp +++ b/components/misc/progressreporter.hpp @@ -29,10 +29,10 @@ namespace Misc { const std::lock_guard lock(mMutex); const auto now = std::chrono::steady_clock::now(); - const auto left = mNextReport - now; - if (left.count() > 0 || provided == expected) + if (mNextReport > now || provided == expected) return false; - mNextReport += mInterval + left; + if (mInterval.count() > 0) + mNextReport = mNextReport + mInterval * ((now - mNextReport + mInterval).count() / mInterval.count()); return true; } (); if (shouldReport)