As it sometimes happens that the object using isc_timer_t is destroyed
via detaching all the references with no guarantee that the last thread
will be matching thread, add a helper isc_timer_async_destroy() function
that stops the timer and runs the destroy function via isc_async_run()
on the matching thread.
* interval.
*/
+void
+isc_timer_async_destroy(isc_timer_t **timerp);
void
isc_timer_destroy(isc_timer_t **timerp);
/*%<
- * Destroy the timer *timerp.
+ * Destroy (asynchronously) the timer *timerp.
*
* Requires:
*
isc_timer_destroy(isc_timer_t **timerp) {
isc__timer_detach(timerp);
}
+
+void
+isc_timer_async_destroy(isc_timer_t **timerp) {
+ isc_timer_t *timer = NULL;
+
+ REQUIRE(timerp != NULL && VALID_TIMER(*timerp));
+
+ timer = *timerp;
+ *timerp = NULL;
+
+ isc_timer_stop(timer);
+ isc_async_run(timer->loop, isc__timer_destroy, timer);
+}