struct QemuCoSleepState {
Coroutine *co;
- QEMUTimer ts;
QemuCoSleepState **user_state_pointer;
};
assert(scheduled == qemu_co_sleep_ns__scheduled);
*sleep_state->user_state_pointer = NULL;
- timer_del(&sleep_state->ts);
aio_co_wake(sleep_state->co);
}
}
QemuCoSleepState **sleep_state)
{
AioContext *ctx = qemu_get_current_aio_context();
+ QEMUTimer ts;
QemuCoSleepState state = {
.co = qemu_coroutine_self(),
.user_state_pointer = sleep_state,
abort();
}
- aio_timer_init(ctx, &state.ts, type, SCALE_NS, co_sleep_cb, sleep_state);
+ aio_timer_init(ctx, &ts, type, SCALE_NS, co_sleep_cb, sleep_state);
*sleep_state = &state;
- timer_mod(&state.ts, qemu_clock_get_ns(type) + ns);
+ timer_mod(&ts, qemu_clock_get_ns(type) + ns);
qemu_coroutine_yield();
+ timer_del(&ts);
/* qemu_co_sleep_wake clears *sleep_state before resuming this coroutine. */
assert(*sleep_state == NULL);