X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=qemu-coroutine-lock.c;h=aeb33b9118a7fec8bade8a385a7923db0efe4cd4;hb=0478f37ce258438d74164dd182b0ae125f174ec6;hp=d9fea4989d43294576d784a95c66990aadbde18f;hpb=338ea905e948613607c98346e127fc9472c57f0d;p=qemu.git diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c index d9fea4989..aeb33b911 100644 --- a/qemu-coroutine-lock.c +++ b/qemu-coroutine-lock.c @@ -88,16 +88,32 @@ static bool qemu_co_queue_do_restart(CoQueue *queue, bool single) return true; } -bool qemu_co_queue_next(CoQueue *queue) +bool coroutine_fn qemu_co_queue_next(CoQueue *queue) { + assert(qemu_in_coroutine()); return qemu_co_queue_do_restart(queue, true); } -void qemu_co_queue_restart_all(CoQueue *queue) +void coroutine_fn qemu_co_queue_restart_all(CoQueue *queue) { + assert(qemu_in_coroutine()); qemu_co_queue_do_restart(queue, false); } +bool qemu_co_enter_next(CoQueue *queue) +{ + Coroutine *next; + + next = QTAILQ_FIRST(&queue->entries); + if (!next) { + return false; + } + + QTAILQ_REMOVE(&queue->entries, next, co_queue_next); + qemu_coroutine_enter(next, NULL); + return true; +} + bool qemu_co_queue_empty(CoQueue *queue) { return (QTAILQ_FIRST(&queue->entries) == NULL);