[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC][PATCH 08/12] coroutine: Add qemu_in_coroutine()
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [RFC][PATCH 08/12] coroutine: Add qemu_in_coroutine() |
Date: |
Sat, 22 Jan 2011 09:29:23 +0000 |
The qemu_in_coroutine() function checks whether or not we are currently
in a user coroutine. This can be used to distinguish between executing
normal vcpu or iothread code from executing a coroutine.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
qemu-coroutine.c | 5 +++++
qemu-coroutine.h | 7 +++++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/qemu-coroutine.c b/qemu-coroutine.c
index e55b7c6..9318600 100644
--- a/qemu-coroutine.c
+++ b/qemu-coroutine.c
@@ -43,3 +43,8 @@ Coroutine * coroutine_fn qemu_coroutine_self(void)
{
return (Coroutine*)coroutine_self();
}
+
+bool qemu_in_coroutine(void)
+{
+ return !coroutine_is_leader(coroutine_self());
+}
diff --git a/qemu-coroutine.h b/qemu-coroutine.h
index 41f90bb..1fad3bf 100644
--- a/qemu-coroutine.h
+++ b/qemu-coroutine.h
@@ -14,6 +14,8 @@
#ifndef QEMU_COROUTINE_H
#define QEMU_COROUTINE_H
+#include <stdbool.h>
+
/**
* Mark a function that executes in coroutine context
*
@@ -78,4 +80,9 @@ void * coroutine_fn qemu_coroutine_yield(void *opaque);
*/
Coroutine * coroutine_fn qemu_coroutine_self(void);
+/**
+ * Return whether or not currently inside a coroutine
+ */
+bool qemu_in_coroutine(void);
+
#endif /* QEMU_COROUTINE_H */
--
1.7.2.3
- [Qemu-devel] [RFC][PATCH 00/12] qcow2: Convert qcow2 to use coroutines for async I/O, Stefan Hajnoczi, 2011/01/22
- [Qemu-devel] [RFC][PATCH 07/12] coroutine: Add coroutine_is_leader(), Stefan Hajnoczi, 2011/01/22
- [Qemu-devel] [RFC][PATCH 08/12] coroutine: Add qemu_in_coroutine(),
Stefan Hajnoczi <=
- [Qemu-devel] [RFC][PATCH 04/12] coroutine: Use thread-local leader and current variables, Stefan Hajnoczi, 2011/01/22
- [Qemu-devel] [RFC][PATCH 09/12] block: Add bdrv_co_readv() and bdrv_co_writev(), Stefan Hajnoczi, 2011/01/22
- [Qemu-devel] [RFC][PATCH 10/12] block: Add coroutine support to synchronous I/O functions, Stefan Hajnoczi, 2011/01/22
- [Qemu-devel] [RFC][PATCH 06/12] coroutine: Add qemu_coroutine_self(), Stefan Hajnoczi, 2011/01/22
- [Qemu-devel] [RFC][PATCH 12/12] qcow2: Serialize all requests, Stefan Hajnoczi, 2011/01/22
- [Qemu-devel] [RFC][PATCH 05/12] coroutine: Add coroutines, Stefan Hajnoczi, 2011/01/22
- [Qemu-devel] [RFC][PATCH 11/12] qcow2: Convert qcow2 to use coroutines for async I/O, Stefan Hajnoczi, 2011/01/22