qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qemu-coroutine: Add simple work queue support


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] qemu-coroutine: Add simple work queue support
Date: Wed, 24 Aug 2011 13:08:26 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Aug 24, 2011 at 05:57:51PM +1000, Peter A. G. Crosthwaite wrote:
> Add a function co_queue_yield_to_next() which will immediately transfer
> control to the coroutine at the head of a co queue. This can be used for
> implementing simple work queues where the manager of a co-queue only
> needs to restart queued routines one at a time.
> 
> Signed-off-by: Peter A. G. Crosthwaite <address@hidden>
> ---
>  qemu-coroutine-lock.c |   13 +++++++++++++
>  qemu-coroutine.h      |    9 +++++++++
>  2 files changed, 22 insertions(+), 0 deletions(-)

Please share code that uses this function, even if it's not suitable for
merging.  I'd like to understand what the pattern for using this
function is.

> diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c
> index a80f437..de2fc21 100644
> --- a/qemu-coroutine-lock.c
> +++ b/qemu-coroutine-lock.c
> @@ -75,6 +75,19 @@ bool qemu_co_queue_next(CoQueue *queue)
>      return (next != NULL);
>  }
> 
> +bool qemu_co_queue_yield_to_next(CoQueue *queue)

This function can only be executed in coroutine context (i.e. it cannot
be executed outside a coroutine).  Therefore please use the coroutine_fn
annotation.  Perhaps we'll hook the annotation up with a checker in the
future to ensure that non-coroutine_fn functions never call coroutine_fn
functions statically at build time.  In the meantime it serves as
documentation.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]