CoQueue: introduce qemu_co_queue_wait_insert_head

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Zhi Yong Wu 2011-11-03 16:57:26 +08:00 committed by Kevin Wolf
parent 0563e19151
commit e9e6295b28
2 changed files with 14 additions and 0 deletions

View File

@ -61,6 +61,14 @@ void coroutine_fn qemu_co_queue_wait(CoQueue *queue)
assert(qemu_in_coroutine());
}
void coroutine_fn qemu_co_queue_wait_insert_head(CoQueue *queue)
{
Coroutine *self = qemu_coroutine_self();
QTAILQ_INSERT_HEAD(&queue->entries, self, co_queue_next);
qemu_coroutine_yield();
assert(qemu_in_coroutine());
}
bool qemu_co_queue_next(CoQueue *queue)
{
Coroutine *next;

View File

@ -117,6 +117,12 @@ void qemu_co_queue_init(CoQueue *queue);
*/
void coroutine_fn qemu_co_queue_wait(CoQueue *queue);
/**
* Adds the current coroutine to the head of the CoQueue and transfers control to the
* caller of the coroutine.
*/
void coroutine_fn qemu_co_queue_wait_insert_head(CoQueue *queue);
/**
* Restarts the next coroutine in the CoQueue and removes it from the queue.
*