qemu-devel
[Top][All Lists]
Advanced

[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 12:15:09 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 02/03/2018 04:54, Peter Xu wrote:
> On Thu, Mar 01, 2018 at 06:13:06PM +0100, Paolo Bonzini wrote:
>> On 01/03/2018 09:44, Peter Xu wrote:
>>> + * qio_channel_add_watch_source:
>>> + * @ioc: the channel object
>>> + * @condition: the I/O condition to monitor
>>> + * @func: callback to invoke when the source becomes ready
>>> + * @user_data: opaque data to pass to @func
>>> + * @notify: callback to free @user_data
>>> + * @context: gcontext to bind the source to
>>> + *
>>> + * Similar as qio_channel_add_watch(), but allows to specify context
>>> + * to run the watch source, meanwhile return the GSource object
>>> + * instead of tag ID, with the GSource referenced already.
>>> + *
>>> + * Note: callers is responsible to unref the source when not needed.
>>> + *
>>> + * Returns: the source pointer
>>> + */
>>> +GSource *qio_channel_add_watch_source(QIOChannel *ioc,
>>> +                                      GIOCondition condition,
>>> +                                      QIOChannelFunc func,
>>> +                                      gpointer user_data,
>>> +                                      GDestroyNotify notify,
>>> +                                      GMainContext *context);
>>>  
>>
>> 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 *.
>>
>> You might therefore name it instead qio_channel_create_watch, for
>> consistency with g_io_{add,create}_watch, and remove the "context" argument.
> 
> Looks like there is already a qio_channel_create_watch() (io/channel.c).
> 
> How about qio_channel_create_watch_attached()?  Or... anything better?

I would add the g_source_set_callback call (and arguments) to
qio_channel_create_watch and leave the g_source_attach to the caller.

Paolo



reply via email to

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