qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] WIP: add GCoroutine support


From: Marc-André Lureau
Subject: Re: [Qemu-devel] [PATCH] WIP: add GCoroutine support
Date: Thu, 22 Jan 2015 02:46:56 +0100

On Thu, Jan 15, 2015 at 4:54 PM, Kevin Wolf <address@hidden> wrote:
> Hm, I guess there might be uses for holding references after the
> coroutine has exited if there are external references to the coroutine,
> but is it useful not to drop one reference after the coroutine exits? I
> guess in most cases, and in qemu always, the caller isn't aware that the
> coroutine ended, so requiring an explicit call isn't as nice as it could
> be.

I thought it would be better to make memory management explicit by the
caller. However, I can also see how inconvenient it is for fire and
forget cases. Unfortunately, the coroutine can't ref/unref() itself at
beginning and end since the "unfinished" warning would show up, also
it feels wrong to unref itself inside the coroutine. So I changed it
to take an implicit ref on resume (similar to g_task_run_in_thread for
ex) and unref automatically when the coroutine finishes. So unlike
qemu-coroutine, you still have a strong reference returned, and must
unref it at some point. This should be similar to GThread/GTask I
think.

Fire and forget fix:
https://github.com/elmarco/gcoroutine/commit/7c88e1f90bb812481883da512a5d7d3b1e7d6028

Copyright fix:
https://github.com/elmarco/gcoroutine/commit/4a513d92e1377a5cd3526eeb8ed974f0a3221636

-- 
Marc-André Lureau



reply via email to

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