From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXZN9-00081u-KP for qemu-devel@nongnu.org; Mon, 05 Dec 2011 09:18:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXZN3-0008Ra-OQ for qemu-devel@nongnu.org; Mon, 05 Dec 2011 09:18:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8356) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXZN3-0008RS-6i for qemu-devel@nongnu.org; Mon, 05 Dec 2011 09:18:17 -0500 From: Kevin Wolf Date: Mon, 5 Dec 2011 15:20:44 +0100 Message-Id: <1323094878-7967-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1323094878-7967-1-git-send-email-kwolf@redhat.com> References: <1323094878-7967-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 07/41] CoQueue: introduce qemu_co_queue_wait_insert_head List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Zhi Yong Wu Signed-off-by: Zhi Yong Wu Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- qemu-coroutine-lock.c | 8 ++++++++ qemu-coroutine.h | 6 ++++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c index 6b58160..9549c07 100644 --- a/qemu-coroutine-lock.c +++ b/qemu-coroutine-lock.c @@ -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; diff --git a/qemu-coroutine.h b/qemu-coroutine.h index b8fc4f4..8a2e5d2 100644 --- a/qemu-coroutine.h +++ b/qemu-coroutine.h @@ -118,6 +118,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. * * Returns true if a coroutine was restarted, false if the queue is empty. -- 1.7.6.4