diff options
| author | Paolo Bonzini | 2021-05-17 12:05:48 +0200 |
|---|---|---|
| committer | Stefan Hajnoczi | 2021-05-21 19:22:33 +0200 |
| commit | 0a6f0c76a030710780ce10d6347a70f098024d21 (patch) | |
| tree | 79401e5d13d95cde502761e07cf3344a0824ac1f /include | |
| parent | coroutine-sleep: replace QemuCoSleepState pointer with struct in the API (diff) | |
| download | qemu-0a6f0c76a030710780ce10d6347a70f098024d21.tar.gz qemu-0a6f0c76a030710780ce10d6347a70f098024d21.tar.xz qemu-0a6f0c76a030710780ce10d6347a70f098024d21.zip | |
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>
Diffstat (limited to 'include')
| -rw-r--r-- | include/qemu/coroutine.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index 82c0671f80..292e61aef0 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -303,6 +303,11 @@ typedef struct QemuCoSleep { void coroutine_fn qemu_co_sleep_ns_wakeable(QemuCoSleep *w, QEMUClockType type, int64_t ns); +/** + * Yield the coroutine until the next call to qemu_co_sleep_wake. + */ +void coroutine_fn qemu_co_sleep(QemuCoSleep *w); + static inline void coroutine_fn qemu_co_sleep_ns(QEMUClockType type, int64_t ns) { QemuCoSleep w = { 0 }; |
