[Spice-devel] [PATCH spice-gtk 4/4] coroutine: make gthread coroutine pass tests
Christophe Fergeau
cfergeau at redhat.com
Tue Nov 19 09:11:24 PST 2013
On Tue, Nov 19, 2013 at 04:14:25PM +0100, Marc-André Lureau wrote:
> The coroutine entry() return value must be passed via the caller->data,
> since coroutine_swap() returns from->data. (this is needed because
> coroutine_swap() argument is used both to return from entry() or to send
> data to a running coroutine)
>
> When leaving a coroutine, clear its caller.
>
> Return correct coroutine_self() before other coroutine are initialized.
> ---
> gtk/coroutine_gthread.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/gtk/coroutine_gthread.c b/gtk/coroutine_gthread.c
> index 3542a82..6ee2587 100644
> --- a/gtk/coroutine_gthread.c
> +++ b/gtk/coroutine_gthread.c
> @@ -74,7 +74,7 @@ static gpointer coroutine_thread(gpointer opaque)
>
> CO_DEBUG("RUNNABLE");
> current = co;
> - co->data = co->entry(co->data);
> + co->caller->data = co->entry(co->data);
> co->exited = 1;
>
I'm not sure I fully grasp that bit, so I'll just assume it's good ;)
> co->caller->runnable = TRUE;
> @@ -128,6 +128,7 @@ void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg)
> g_cond_wait(run_cond, run_lock);
> }
> current = from;
> + to->caller = NULL;
>
> CO_DEBUG("SWAPPED");
> return from->data;
> @@ -135,6 +136,9 @@ void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg)
>
> struct coroutine *coroutine_self(void)
> {
> + if (run_cond == NULL)
> + coroutine_system_init();
That hunk probably means the (coroutine_self() == NULL) check in
coroutine_is_main() is no longer useful.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20131119/4bedb050/attachment-0001.pgp>
More information about the Spice-devel
mailing list