From 371664ac437c075711d7ec474054f4c5521541a5 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sat, 15 Feb 2025 12:26:45 -0600 Subject: [PATCH] fix polling --- repertory/librepertory/src/utils/polling.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/repertory/librepertory/src/utils/polling.cpp b/repertory/librepertory/src/utils/polling.cpp index 2561e4af..e74b9dbe 100644 --- a/repertory/librepertory/src/utils/polling.cpp +++ b/repertory/librepertory/src/utils/polling.cpp @@ -30,6 +30,7 @@ #include "events/types/service_stop_begin.hpp" #include "events/types/service_stop_end.hpp" #include "utils/tasks.hpp" +#include namespace repertory { polling polling::instance_; @@ -40,11 +41,12 @@ void polling::frequency_thread( auto last_run = std::chrono::system_clock::time_point::min(); while (not get_stop_requested()) { - auto elapsed = std::chrono::system_clock::now() - last_run; + auto elapsed = std::chrono::duration_cast( + std::chrono::system_clock::now() - last_run); auto max_elapsed = std::chrono::seconds(get_frequency_seconds()); - if (std::chrono::duration_cast(elapsed) >= - max_elapsed) { + if (last_run == std::chrono::system_clock::time_point::min() || + elapsed >= max_elapsed) { unique_mutex_lock lock(mutex_); auto futures = std::accumulate( items_.begin(), items_.end(), std::deque{},