[Spice-devel] [spice-gtk v2] Introduce gtask-helper.[ch]
Christophe Fergeau
cfergeau at redhat.com
Fri May 13 13:11:31 UTC 2016
Hey,
On Fri, May 13, 2016 at 02:30:25PM +0200, Victor Toso wrote:
> With that said, I'd like to suggest a change in the gtask-helper.
> Quoting the fine manual from GTask:
> "The "return" methods (eg, g_task_return_pointer()) automatically cause
> the task to be "completed" as well, and there is no need to worry about
> the "complete" vs "complete in idle" distinction. (GTask automatically
> figures out whether the task's callback can be invoked directly, or if
> it needs to be sent to another GMainContext, or delayed until the next
> iteration of the current GMainContext.)"
>
> I would like that gtaskhelper do what the GTask can't at this moment
> with the coroutine context which is "not make us worry about complete vs
> complete in idle"
>
> I would like to know what you think about changing
> g_task_helper_return_int_in_idle to g_task_helper_return_int. The
> non-idle version should then check if we are in the main-context using
> coroutine_self_is_main(). If we are in the main-context, I would say we
> can let g_task_return_int decide when to call the callback. If we are in
> coroutine context, we can return in idle.
>
> This approach would let us be closer to the gtask behavior/intention; we
> would only be handling the coroutine context that gtask can't at the
> moment.
I don't think I agree with this approach. Hiding it in gtask-helper
would mean that we think that all our GTask callbacks happening in a coroutine
context need to happen in a main context.
What you could do is record in which coroutine context you are at GTask
creation, and compare to the context we are in when returning from the
coroutine, but that adds even more complication...
You would also need more magic to guarantee a coroutine switch before
the callback is called in an idle (or are all idles called in the main
context? I forgot this). In this case, my understanding is that the code
was working before because something between the
g_simple_async_result_return_in_idle and the invocation of the idle
callback was triggering a coroutine switch.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160513/7e766a15/attachment.sig>
More information about the Spice-devel
mailing list