static void test_detach_attach(void) { /* zero structures */ memset(&ts, 0, sizeof(ts)); memset(&tt, 0, sizeof(tt)); /* init the structure */ throttle_init(&ts); throttle_timers_init(&tt, ctx, QEMU_CLOCK_VIRTUAL, read_timer_cb, write_timer_cb, &ts); /* timer set by init should return true */ g_assert(throttle_timers_are_initialized(&tt)); /* timer should no longer exist after detaching */ throttle_timers_detach_aio_context(&tt); g_assert(!throttle_timers_are_initialized(&tt)); /* timer should exist again after attaching */ throttle_timers_attach_aio_context(&tt, ctx); g_assert(throttle_timers_are_initialized(&tt)); throttle_timers_destroy(&tt); }
/* To be called last on the ThrottleTimers */ void throttle_timers_destroy(ThrottleTimers *tt) { throttle_timers_detach_aio_context(tt); }