diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2022-04-27 15:08:29 +0200 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-05-12 12:29:44 +0200 |
| commit | d6ee15adec5a2345e88c680cd15ed48796c89c14 (patch) | |
| tree | 423cf9a8014a44af30a1047a1342fba81735d968 /include/qemu/coroutine.h | |
| parent | 248af9e80a04c5ab4ffec789aa24345d3d86b42b (diff) | |
| download | focaccia-qemu-d6ee15adec5a2345e88c680cd15ed48796c89c14.tar.gz focaccia-qemu-d6ee15adec5a2345e88c680cd15ed48796c89c14.zip | |
coroutine-lock: introduce qemu_co_queue_enter_all
Because qemu_co_queue_restart_all does not release the lock, it should be used only in coroutine context. Introduce a new function that, like qemu_co_enter_next, does release the lock, and use it whenever qemu_co_queue_restart_all was used outside coroutine context. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20220427130830.150180-3-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qemu/coroutine.h')
| -rw-r--r-- | include/qemu/coroutine.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index c23d41e1ff..e5954635f6 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -235,6 +235,19 @@ void qemu_co_queue_restart_all(CoQueue *queue); bool qemu_co_enter_next_impl(CoQueue *queue, QemuLockable *lock); /** + * Empties the CoQueue, waking the waiting coroutine one at a time. Unlike + * qemu_co_queue_all, this function releases the lock during aio_co_wake + * because it is meant to be used outside coroutine context; in that case, the + * coroutine is entered immediately, before qemu_co_enter_all returns. + * + * If used in coroutine context, qemu_co_enter_all is equivalent to + * qemu_co_queue_all. + */ +#define qemu_co_enter_all(queue, lock) \ + qemu_co_enter_all_impl(queue, QEMU_MAKE_LOCKABLE(lock)) +void qemu_co_enter_all_impl(CoQueue *queue, QemuLockable *lock); + +/** * Checks if the CoQueue is empty. */ bool qemu_co_queue_empty(CoQueue *queue); |