qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC][PATCH 05/12] coroutine: Add coroutines


From: Anthony Liguori
Subject: Re: [Qemu-devel] [RFC][PATCH 05/12] coroutine: Add coroutines
Date: Wed, 26 Jan 2011 10:00:52 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Lightning/1.0b1 Thunderbird/3.0.10

On 01/26/2011 09:29 AM, Avi Kivity wrote:
On 01/22/2011 11:29 AM, Stefan Hajnoczi wrote:
Add functions to create coroutines and transfer control into a coroutine
and back out again.


+
+struct Coroutine {
+    struct coroutine co;
+};
+

+/**
+ * Coroutine entry point
+ *
+ * When the coroutine is entered for the first time, opaque is passed in as an
+ * argument.
+ *
+ * When this function returns, the coroutine is destroyed automatically and the + * return value is passed back to the caller who last entered the coroutine.
+ */
+typedef void * coroutine_fn CoroutineEntry(void *opaque);

The more modern style is to use the Coroutine structure as argument, and let the coroutine function use container_of() to obtain access to its own data structures. Similarly it can store any return value there, avoiding casts to and from void pointers.

This is old (shared) code from other projects. My plan is to split into a separate library instead of actually including this in QEMU.

Regards,

Anthony Liguori





reply via email to

[Prev in Thread] Current Thread [Next in Thread]