[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 5/7] coroutine: add qemu_coroutine_entered() function
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 5/7] coroutine: add qemu_coroutine_entered() function |
Date: |
Wed, 28 Sep 2016 19:15:35 +0100 |
See the doc comments for a description of this new coroutine API.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
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);
/**
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;
+}
--
2.7.4
- [Qemu-devel] [PULL 0/7] Block patches, Stefan Hajnoczi, 2016/09/28
- [Qemu-devel] [PULL 1/7] block: mirror: fix wrong comment of mirror_start, Stefan Hajnoczi, 2016/09/28
- [Qemu-devel] [PULL 2/7] aio-posix: avoid unnecessary aio_epoll_enabled() calls, Stefan Hajnoczi, 2016/09/28
- [Qemu-devel] [PULL 5/7] coroutine: add qemu_coroutine_entered() function,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 7/7] linux-aio: fix re-entrant completion processing, Stefan Hajnoczi, 2016/09/28
- [Qemu-devel] [PULL 4/7] libqos: fix qvring_init(), Stefan Hajnoczi, 2016/09/28
- [Qemu-devel] [PULL 3/7] iothread: check iothread->ctx before aio_context_unref to avoid assertion, Stefan Hajnoczi, 2016/09/28
- [Qemu-devel] [PULL 6/7] test-coroutine: test qemu_coroutine_entered(), Stefan Hajnoczi, 2016/09/28
- Re: [Qemu-devel] [PULL 0/7] Block patches, Peter Maydell, 2016/09/28