Hi Stefan,

I have ccd you on a RFC containing the work that this patch uses. I have
also changed the name of the function to co_queue_enter_next() as i think
yield was not the appropriate name. The idea is the top level thread which
is managing the work queue can transfer into coroutine context with the
function, so this function is more of an "enter" function than a "yield"
function. I cant see any technical reasons why it needs the coroutine_fn
restriction, as this in not required by qemu_coroutine_enter, which is the
backend of this function.

Regards and thanks for your comments,
Peter

On Wed, Aug 24, 2011 at 10:08 PM, Stefan Hajnoczi <
stefa...@linux.vnet.ibm.com> wrote:

> 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 <peter.crosthwa...@petalogix.com>
> > ---
> >  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