From b9e3cd5d2a75f962a1e88cbe676cf875a796543d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 17 Feb 2025 14:58:28 +0100 Subject: [PATCH] Add isc_timer_running() function to check status of timer In the next commit, we need to know whether the timer has been started or stopped. Add isc_timer_running() function that returns true if the timer has been started. --- lib/isc/include/isc/timer.h | 10 ++++++++++ lib/isc/timer.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/isc/include/isc/timer.h b/lib/isc/include/isc/timer.h index 9d1e95a1d1..873ebd197d 100644 --- a/lib/isc/include/isc/timer.h +++ b/lib/isc/include/isc/timer.h @@ -152,3 +152,13 @@ isc_timer_destroy(isc_timer_t **timerp); * *\li *timerp is NULL. */ + +bool +isc_timer_running(isc_timer_t *timer); +/*%< + * Return true if the timer has been started. + * + * Requires: + * + *\li 'timer' is a valid timer* + */ diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 4d30409084..bfd3377f4c 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -196,3 +197,10 @@ isc_timer_async_destroy(isc_timer_t **timerp) { isc_timer_stop(timer); isc_async_run(timer->loop, timer_destroy, timer); } + +bool +isc_timer_running(isc_timer_t *timer) { + REQUIRE(VALID_TIMER(timer)); + + return atomic_load_acquire(&timer->running); +}