diff options
-rw-r--r-- | include/qemu/coroutine.h | 13 | ||||
-rw-r--r-- | ui/console.c | 2 | ||||
-rw-r--r-- | util/qemu-coroutine-lock.c | 7 |
3 files changed, 21 insertions, 1 deletions
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index c23d41e..e595463 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); diff --git a/ui/console.c b/ui/console.c index 15d0f6a..36c80cd 100644 --- a/ui/console.c +++ b/ui/console.c @@ -221,7 +221,7 @@ static void gui_setup_refresh(DisplayState *ds) void graphic_hw_update_done(QemuConsole *con) { if (con) { - qemu_co_queue_restart_all(&con->dump_queue); + qemu_co_enter_all(&con->dump_queue, NULL); } } diff --git a/util/qemu-coroutine-lock.c b/util/qemu-coroutine-lock.c index 5705cfe..5b0342f 100644 --- a/util/qemu-coroutine-lock.c +++ b/util/qemu-coroutine-lock.c @@ -108,6 +108,13 @@ bool coroutine_fn qemu_co_queue_next(CoQueue *queue) return qemu_co_enter_next_impl(queue, NULL); } +void qemu_co_enter_all_impl(CoQueue *queue, QemuLockable *lock) +{ + while (qemu_co_enter_next_impl(queue, lock)) { + /* just loop */ + } +} + bool qemu_co_queue_empty(CoQueue *queue) { return QSIMPLEQ_FIRST(&queue->entries) == NULL; |