Re: watching a file descriptor in gtk3
- From: rbd <rbd soest hawaii edu>
- To: Emmanuele Bassi <ebassi gmail com>
- Cc: Chris Vine <chris cvine freeserve co uk>, "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: watching a file descriptor in gtk3
- Date: Mon, 23 Jan 2017 13:17:25 -1000 (HST)
Hi Emmanuele,
Thanks for the additional documentation references! They were generally
informative, although I think the one you mentioned as being apropos of my
particular case was actually designed to be used for a source specifically
other than file descriptors -- it was useful nonetheless, however.
Roger
On Mon, 23 Jan 2017, Emmanuele Bassi wrote:
Hi;
On 23 January 2017 at 22:09, rbd <rbd soest hawaii edu> wrote:
It is not quite that bad. The documentation for g_source_add_unix_fd()
is inadequate, but although not immediately obvious the prepare, check
and finalize handlers can in fact usually just be set to NULL (provided
you have set the 'events' argument for g_source_add_unix_fd()
correctly) so you only need to provide the dispatch handler, which
executes your callback when an event occurs.
The poor quality of the documentation is the real problem here. I
would give it a try and see how you get on with it.
Nothing about the g_source_* functions is obvious from the official docs,
either immediately or otherwise! ;-> Seriously, one of the least illuminated
points there actually has to do with timeouts, exactly where in the
check->prepare->dispatch sequence the poll() gets done, etc.
Of course, patches and bugs for the documentation are welcome.
A good set of articles on GSource and the main context API in GLib is
on Philip Withnall's blog; Philip actually contributed back that
documentation in the API reference, but this kind of discussions on
how the implementation works is ill-suited for an API documentation.
See:
- https://tecnocode.co.uk/2014/03/27/what-is-gmaincontext/
- https://tecnocode.co.uk/2015/05/05/a-detailed-look-at-gsource/
- https://tecnocode.co.uk/2014/04/19/ensuring-functions-are-called-in-the-right-context/
The second article also covers your use case pretty accurately.
Ciao,
Emmanuele.
--
https://www.bassi.io
[@] ebassi [@gmail.com]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]