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: Thu, 1 Mar 2018 18:13:06 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

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.

(Not making it perfectly the same API is okay, for example in practice
all callers would use g_source_set_callback so it's okay IMO to add the
three arguments func/user_data/notify.  However, inconsistency on
g_source_add is more subtle).

Thanks,

Paolo



reply via email to

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