Should there be a way to query if an event queue is empty?

Neil Roberts neil at linux.intel.com
Fri Jul 26 05:30:58 PDT 2013


Hi,

[I sent this yesterday too, but I accidentally used the wrong address
and it got stuck in the moderator queue so I'm resending it]

I was wondering whether we should add a function like
wl_event_queue_empty() to query whether there are any pending events in
the queue. This would make it easier to integrate with a GLib-style main
loop more cleanly.

A source on the GLib main loop works with a ‘prepare’ function that is
called before blocking in poll which sets the fds and the time to wait
on. When the poll is complete, if those conditions are met then a
‘dispatch’ function will be called. The source wouldn't normally be
expected to do any work during the prepare function which means that all
of the events should be handled in the dispatch function. I don't think
there's any way to do this with the current Wayland API because you have
to call wl_display_dispatch_pending before blocking in poll, which means
you have to do it in the prepare. This could end up processing events
and calling callbacks which the application might not be expecting to
handle at this point.

If there was a way to query whether the event queue is empty, then the
prepare function could return TRUE which means it is immediately ready.
GLib would then call poll with a zero timeout so that it would wake up
immediately and the call to wl_display_dispatch_pending could be delayed
to the dispatch callback.

The Cogl Wayland backend would benefit from this too. Currently Cogl
just calls wl_display_dispatch_pending in the prepare but this somewhat
goes against our promise that we won't call any callbacks outside of
cogl_poll_renderer_dispatch().

http://is.gd/06hbob

Regards,
- Neil
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


More information about the wayland-devel mailing list