RefreshData clang-tidy fixes

(cherry picked from commit c630c2969929ce46d96fd4f941f054dcc70d1d8b)
This commit is contained in:
Dan Paulat 2025-09-03 22:38:56 -05:00
parent 3fe7dd9eed
commit f34d11a7ea

View file

@ -106,7 +106,7 @@ public:
group, product, isChunks_, latestTime); group, product, isChunks_, latestTime);
}); });
} }
~ProviderManager() ~ProviderManager() override
{ {
providerThreadPool_.stop(); providerThreadPool_.stop();
providerThreadPool_.join(); providerThreadPool_.join();
@ -797,12 +797,12 @@ void ProviderManager::RefreshData()
logger_->trace("RefreshData: {}", name()); logger_->trace("RefreshData: {}", name());
{ {
std::unique_lock lock(refreshTimerMutex_); const std::unique_lock lock(refreshTimerMutex_);
refreshTimer_.cancel(); refreshTimer_.cancel();
} }
boost::asio::post(providerThreadPool_, boost::asio::post(providerThreadPool_,
[=, this]() [this]()
{ {
try try
{ {
@ -841,7 +841,11 @@ void ProviderManager::RefreshDataSync()
interval = std::chrono::duration_cast<std::chrono::milliseconds>( interval = std::chrono::duration_cast<std::chrono::milliseconds>(
updatePeriod - sinceLastModified); updatePeriod - sinceLastModified);
if (updatePeriod > 0s && sinceLastModified > updatePeriod * 5) // Allow 5 update periods before considering the data stale
constexpr std::size_t kUpdatePeriodStaleCount = 5;
if (updatePeriod > 0s &&
sinceLastModified > updatePeriod * kUpdatePeriodStaleCount)
{ {
// If it has been at least 5 update periods since the file has // If it has been at least 5 update periods since the file has
// been last modified, slow the retry period // been last modified, slow the retry period
@ -878,7 +882,7 @@ void ProviderManager::RefreshDataSync()
{ {
refreshTimer_.expires_after(interval); refreshTimer_.expires_after(interval);
refreshTimer_.async_wait( refreshTimer_.async_wait(
[=, this](const boost::system::error_code& e) [this](const boost::system::error_code& e)
{ {
if (e == boost::system::errc::success) if (e == boost::system::errc::success)
{ {