mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 10:12:09 -04:00
Add isc_timer_async_destroy() helper function
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.
This commit is contained in:
parent
3a735998bc
commit
27d1e498b8
2 changed files with 16 additions and 1 deletions
|
|
@ -140,10 +140,12 @@ isc_timer_start(isc_timer_t *timer, isc_timertype_t type,
|
|||
* 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:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -225,3 +225,16 @@ void
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue