Received: from eggs.gnu.org ([2001:4830:134:3::10]:51485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bov75-00051T-Mu for qemu-devel@nongnu.org; Tue, 27 Sep 2016 12:20:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bov74-0005yH-P4 for qemu-devel@nongnu.org; Tue, 27 Sep 2016 12:20:11 -0400 Sender: Paolo Bonzini References: <1474985217-21690-1-git-send-email-stefanha@redhat.com> <1474985217-21690-2-git-send-email-stefanha@redhat.com> From: Paolo Bonzini Message-ID: <059434c4-67c0-9d8f-8089-e58d7fe952fc@redhat.com> Date: Tue, 27 Sep 2016 18:20:03 +0200 MIME-Version: 1.0 In-Reply-To: <1474985217-21690-2-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/3] coroutine: add qemu_coroutine_entered() function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Roman Pen , qemu-block@nongnu.org On 27/09/2016 16:06, Stefan Hajnoczi wrote: > See the doc comments for a description of this new coroutine API. > > Signed-off-by: Stefan Hajnoczi > --- > include/qemu/coroutine.h | 13 +++++++++++++ > util/qemu-coroutine.c | 5 +++++ > 2 files changed, 18 insertions(+) > > diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h > index 29a2078..e6a60d5 100644 > --- a/include/qemu/coroutine.h > +++ b/include/qemu/coroutine.h > @@ -92,6 +92,19 @@ Coroutine *coroutine_fn qemu_coroutine_self(void); > */ > bool qemu_in_coroutine(void); > > +/** > + * Return true if the coroutine is currently entered > + * > + * A coroutine is "entered" if it has not yielded from the current > + * qemu_coroutine_enter() call used to run it. This does not mean that the > + * coroutine is currently executing code since it may have transferred control > + * to another coroutine using qemu_coroutine_enter(). > + * > + * When several coroutines enter each other there may be no way to know which > + * ones have already been entered. In such situations this function can be > + * used to avoid recursively entering coroutines. > + */ > +bool qemu_coroutine_entered(Coroutine *co); Perhaps qemu_coroutine_running is a better name? Paolo > > > /** > diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c > index 3cbf225..737bffa 100644 > --- a/util/qemu-coroutine.c > +++ b/util/qemu-coroutine.c > @@ -146,3 +146,8 @@ void coroutine_fn qemu_coroutine_yield(void) > self->caller = NULL; > qemu_coroutine_switch(self, to, COROUTINE_YIELD); > } > + > +bool qemu_coroutine_entered(Coroutine *co) > +{ > + return co->caller; > +} >