From 39c1d10583bf258245a158e1f3434e52f4619401 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Thu, 25 Sep 2025 09:49:17 +0200 Subject: [PATCH] checker: make result timer interval configurable for testing --- lib/checker/checkercomponent.cpp | 17 ++++++++++++++++- lib/checker/checkercomponent.hpp | 8 ++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/checker/checkercomponent.cpp b/lib/checker/checkercomponent.cpp index 525d15705..d400b2b10 100644 --- a/lib/checker/checkercomponent.cpp +++ b/lib/checker/checkercomponent.cpp @@ -71,7 +71,7 @@ void CheckerComponent::Start(bool runtimeCreated) m_Thread = std::thread([this]() { CheckThreadProc(); }); m_ResultTimer = Timer::Create(); - m_ResultTimer->SetInterval(5); + m_ResultTimer->SetInterval(m_ResultTimerInterval); m_ResultTimer->OnTimerExpired.connect([this](const Timer * const&) { ResultTimerHandler(); }); m_ResultTimer->Start(); } @@ -376,3 +376,18 @@ unsigned long CheckerComponent::GetPendingCheckables() return m_PendingCheckables.size(); } + +/** + * Sets the interval in seconds for the result timer. + * + * The result timer periodically logs the number of pending and idle checkables + * as well as the checks per second rate. The default interval is 5 seconds. + * + * Note, this method must be called before the component is started to have an effect on the timer. + * + * @param interval Interval in seconds for the result timer. + */ +void CheckerComponent::SetResultTimerInterval(double interval) +{ + m_ResultTimerInterval = interval; +} diff --git a/lib/checker/checkercomponent.hpp b/lib/checker/checkercomponent.hpp index 88cb47797..dfd34f540 100644 --- a/lib/checker/checkercomponent.hpp +++ b/lib/checker/checkercomponent.hpp @@ -73,12 +73,16 @@ public: unsigned long GetIdleCheckables(); unsigned long GetPendingCheckables(); + void SetResultTimerInterval(double interval); + private: std::mutex m_Mutex; std::condition_variable m_CV; bool m_Stopped{false}; std::thread m_Thread; + double m_ResultTimerInterval{5.0}; // Interval in seconds for the result timer. + CheckableSet m_IdleCheckables; CheckableSet m_PendingCheckables; @@ -90,13 +94,9 @@ private: void ExecuteCheckHelper(const Checkable::Ptr& checkable); - void AdjustCheckTimer(); - void ObjectHandler(const ConfigObject::Ptr& object); void NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck = -1); - void RescheduleCheckTimer(); - static CheckableScheduleInfo GetCheckableScheduleInfo(const Checkable::Ptr& checkable); };