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

Neil Roberts neil at linux.intel.com
Sat Jul 27 13:22:27 PDT 2013


Bill Spitzak <spitzak at gmail.com> writes:

> I think that rather than some trick to fool glib into making the poll 
> return immmediately, calling dispatch_pending in a loop until it returns 
> false will work better, and the poll can be called normally.

I wouldn't consider this to be a ‘trick’. It's normal and documented to
return TRUE from the prepare function if you are immediately ready to
dispatch. This is similar to how the GSource works for reading X events.
It will call XPending in the prepare function and return TRUE if there
are already events pending. It wouldn't immediately try to consume those
events in the prepare function, but instead it would wait until the
dispatch.

> If glib does not reliably call something before the poll (possibly
> documented as something "after the last dispatch function", as the end
> of the loop is identical to the start of the next loop) then I don't
> see any way to fix this other than to change glib, or require that all
> dispatch functions know about wayland and call the wayland dispatch.

GLib does reliably call the prepare functions before the poll. There is
no problem using wl_dispatch_prepare_read() with GLib as far as I know.
The problem I was mentioning is with the Cogl API, but as I said, I'm
not sure if it's worth making changes to Wayland to accomodate that
considering we could probably change Cogl instead.

So in summary I no longer think Wayland really needs to do anything
different.

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