coroutine-sleep: introduce qemu_co_sleep
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 17 May 2021 10:05:48 +0000 (12:05 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 21 May 2021 17:22:33 +0000 (18:22 +0100)
commit0a6f0c76a030710780ce10d6347a70f098024d21
tree79401e5d13d95cde502761e07cf3344a0824ac1f
parent29a6ea24eb85d8400df1607a9e11d0ef9ec5e88d
coroutine-sleep: introduce qemu_co_sleep

Allow using QemuCoSleep to sleep forever until woken by qemu_co_sleep_wake.
This makes the logic of qemu_co_sleep_ns_wakeable easy to understand.

In the future we will introduce an API that can work even if the
sleep and wake happen from different threads.  For now, initializing
w->to_wake after timer_mod is fine because the timer can only fire in
the same AioContext.

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 20210517100548.28806-7-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
include/qemu/coroutine.h
util/qemu-coroutine-sleep.c