]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add isc_timer_running() function to check status of timer
authorOndřej Surý <ondrej@isc.org>
Mon, 17 Feb 2025 13:58:28 +0000 (14:58 +0100)
committerOndřej Surý <ondrej@isc.org>
Fri, 21 Feb 2025 21:05:43 +0000 (22:05 +0100)
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
lib/isc/timer.c

index 9d1e95a1d1b7163b86257aaf639bf1663e120dff..873ebd197d6501be6e2374af2e9a94ce3799f53a 100644 (file)
@@ -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*
+ */
index 4d30409084844b9df4a16e17e13e8ba487c0b53c..bfd3377f4c30c0871eeb58f8b4012a25cf693612 100644 (file)
@@ -16,6 +16,7 @@
 #include <stdbool.h>
 
 #include <isc/async.h>
+#include <isc/atomic.h>
 #include <isc/condition.h>
 #include <isc/heap.h>
 #include <isc/job.h>
@@ -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);
+}