After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 790948 - GSourceFuncs documentation is confusing: when will dispatch be called?
GSourceFuncs documentation is confusing: when will dispatch be called?
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: docs
2.55.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2017-11-28 15:48 UTC by Michael Catanzaro
Modified: 2017-11-29 19:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gmain: Improve documentation of GSourceFuncs (3.86 KB, patch)
2017-11-28 15:59 UTC, Michael Catanzaro
committed Details | Review

Description Michael Catanzaro 2017-11-28 15:48:23 UTC
I am confused by the documentation of GSourceFuncs. The documentation indicates that dispatch is only called if either prepare or check returns TRUE. It also indicates that if prepare or check is NULL, then it is treated as if that function returned FALSE. So if both prepare and check are NULL, then dispatch should never be called. However, the GSocketSource implementation until recently used NULL for both prepare and check. So I am missing something. Clearly, in practice, both functions can be NULL, and the source will actually be dispatched, contrary to the documentation.

Looking at the implementation of g_main_context_prepare(), I see that g_source_set_ready_time() effectively overrides the result of prepare, ensuring that dispatch is called. This is sort of documented in the description of g_source_set_ready_time(), but the interaction between the ready time and prepare/check is not mentioned.
Comment 1 Michael Catanzaro 2017-11-28 15:59:32 UTC
Created attachment 364575 [details] [review]
gmain: Improve documentation of GSourceFuncs

We should more clearly indicate that a source ready time will result in
a source being dispatched even if prepare and check never return TRUE.
Comment 2 Philip Withnall 2017-11-29 17:31:40 UTC
Review of attachment 364575 [details] [review]:

Looks good to me.
Comment 3 Michael Catanzaro 2017-11-29 19:21:06 UTC
Attachment 364575 [details] pushed as 7f639fd - gmain: Improve documentation of GSourceFuncs