2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

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.
This commit is contained in:
Ondřej Surý 2025-02-17 14:58:28 +01:00
parent e127ba0041
commit b9e3cd5d2a
No known key found for this signature in database
GPG Key ID: 2820F37E873DEA41
2 changed files with 18 additions and 0 deletions

View File

@ -152,3 +152,13 @@ isc_timer_destroy(isc_timer_t **timerp);
* *
*\li *timerp is NULL. *\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*
*/

View File

@ -16,6 +16,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <isc/async.h> #include <isc/async.h>
#include <isc/atomic.h>
#include <isc/condition.h> #include <isc/condition.h>
#include <isc/heap.h> #include <isc/heap.h>
#include <isc/job.h> #include <isc/job.h>
@ -196,3 +197,10 @@ isc_timer_async_destroy(isc_timer_t **timerp) {
isc_timer_stop(timer); isc_timer_stop(timer);
isc_async_run(timer->loop, timer_destroy, 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);
}