Patchwork [RFC,06/12] coroutine: Add qemu_coroutine_self()

login
register
mail settings
Submitter Stefan Hajnoczi
Date Jan. 22, 2011, 9:29 a.m.
Message ID <1295688567-25496-7-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/79986/
State New
Headers show

Comments

Stefan Hajnoczi - Jan. 22, 2011, 9:29 a.m.
Add a function to get the current coroutine.  There is always a current
coroutine, either the "leader" (default main coroutine) or a specific
coroutine created with qemu_coroutine_create().

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 qemu-coroutine.c |    5 +++++
 qemu-coroutine.h |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)

Patch

diff --git a/qemu-coroutine.c b/qemu-coroutine.c
index dd2cd8e..e55b7c6 100644
--- a/qemu-coroutine.c
+++ b/qemu-coroutine.c
@@ -38,3 +38,8 @@  void * coroutine_fn qemu_coroutine_yield(void *opaque)
 {
     return coroutine_yield(opaque);
 }
+
+Coroutine * coroutine_fn qemu_coroutine_self(void)
+{
+    return (Coroutine*)coroutine_self();
+}
diff --git a/qemu-coroutine.h b/qemu-coroutine.h
index 22fe4ea..41f90bb 100644
--- a/qemu-coroutine.h
+++ b/qemu-coroutine.h
@@ -73,4 +73,9 @@  void *qemu_coroutine_enter(Coroutine *coroutine, void *opaque);
  */
 void * coroutine_fn qemu_coroutine_yield(void *opaque);
 
+/**
+ * Get the currently executing coroutine
+ */
+Coroutine * coroutine_fn qemu_coroutine_self(void);
+
 #endif /* QEMU_COROUTINE_H */