From: Gabriel Kerneis <gabriel@kerneis.info>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@gmail.com, pbonzini@redhat.com,
Gabriel Kerneis <gabriel@kerneis.info>,
charlie@ctshepherd.com
Subject: [Qemu-devel] [RFC] Introduce blocking_fn annotation
Date: Fri, 6 Sep 2013 15:30:39 +0100 [thread overview]
Message-ID: <1378477839-7353-2-git-send-email-gabriel@kerneis.info> (raw)
In-Reply-To: <1378477839-7353-1-git-send-email-gabriel@kerneis.info>
A blocking function is a function that must not be called in coroutine
context, for example because it might block for a long amount of time.
This annotation should be used to mark normal functions that have a
coroutine_fn counterpart, to make sure that the former is not used
instead of the later in coroutine context.
Signed-off-by: Gabriel Kerneis <gabriel@kerneis.info>
---
include/block/coroutine.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/include/block/coroutine.h b/include/block/coroutine.h
index 4232569..a92d14f 100644
--- a/include/block/coroutine.h
+++ b/include/block/coroutine.h
@@ -46,6 +46,29 @@
*/
#define coroutine_fn
+/**
+ * Mark a function that executes in blocking context
+ *
+ * Functions that execute in blocking context cannot be called directly from
+ * coroutine functions. In the future it would be nice to enable compiler or
+ * static checker support for catching such errors. This annotation might make
+ * it possible and in the meantime it serves as documentation.
+ *
+ * Annotating a function as "blocking" is stronger than having a mere
+ * (unannotated) normal function. It means that it might block the main
+ * loop for a significant amount of time, and therefore must not be
+ * called in coroutine context. In general, its hints that an
+ * alternative coroutine function performing the same taks is available
+ * for use in coroutine context.
+ *
+ * For example:
+ *
+ * static void blocking_fn foo(void) {
+ * ....
+ * }
+ */
+#define blocking_fn
+
typedef struct Coroutine Coroutine;
/**
--
1.7.10.4
next prev parent reply other threads:[~2013-09-06 14:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-06 14:30 [Qemu-devel] [RFC] Introducing CoroCheck and proposal for a blocking_fn annotation Gabriel Kerneis
2013-09-06 14:30 ` Gabriel Kerneis [this message]
2013-09-06 14:46 ` Gabriel Kerneis
2013-09-06 15:36 ` Charlie Shepherd
2013-09-06 16:05 ` Gabriel Kerneis
2013-09-06 16:28 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378477839-7353-2-git-send-email-gabriel@kerneis.info \
--to=gabriel@kerneis.info \
--cc=charlie@ctshepherd.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).