[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 03/15] qio: introduce qio_channel_add_watch_{
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH v2 03/15] qio: introduce qio_channel_add_watch_{full|source} |
Date: |
Fri, 2 Mar 2018 16:53:19 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 02/03/2018 16:44, Daniel P. Berrangé wrote:
>> Just a small thing, this is a bit inconsistent with the rest of the
>> GSource API, where the g_source_attach is usually left to the caller
>> when a function returns GSource *.
> The APIs which return a GSource in glib typically don't even set the
> callback function - we already cover that scenario with the
> qio_channel_create_watch APIs.
>
> GLib doesn't typically have APIs which return a GSource after the
> mix of creating the watch, setting callback & attaching to context.
True, on the other hand it's annoying for qio_channel_create_watch
because of the function pointer case. So I suggested a mix of creating
the watch and setting the callback.
Having a function that takes a GMainContext and returns a tag is fine, too.
Paolo
> They all just return the watch ID value.
>
> So I think this proposal is ok as it is as there's no real precedence.
>
> Alternatively we could simply do without this API entirely. It is
> trivial enough for the code that needs a GSource to get iuse the
> normal qio_channel_add_watch|watch_full APIs, and then lookup the
> GSource themselves - only one extra line of code in the callers.
- [Qemu-devel] [PATCH v2 02/15] qio: rename qio_task_thread_result, (continued)
[Qemu-devel] [PATCH v2 05/15] qio: refactor net listener source operations, Peter Xu, 2018/03/01
[Qemu-devel] [PATCH v2 06/15] qio: store gsources for net listeners, Peter Xu, 2018/03/01