idle tasks starving in toytoolkit

Neil Roberts neil at
Fri Sep 27 03:38:53 PDT 2013

Pekka Paalanen <ppaalanen at> writes:

> If not, is there not a possibility to break existing applications by
> blocking too early?

Yes, you're right, the patch is nonsense because it won't work when the
application does wl_display_dispatch_pending because it might end up
with some events still in the queue but the poll won't wake up to
process them.

It would be nice if the recommended main loop was more like this:

 while (TRUE) {
   int need_read;
   int timeout;

   if (wl_display_prepare_read(display)) {
     need_read = 1;
     timeout = -1;
   } else {
     need_read = 0;
     timeout = 0;


   poll(fds, nfds, timeout);

   if (need_read)


That way it doesn't matter if wl_display_dispatch_pending doesn't clear
all of the events.

That is effectively what I think we need do in GTK anyway because in
that case you really ought to avoid dispatching events in the prepare
function before the poll and instead should only be dispatching after.

I guess it's too late to change the semantics of
wl_display_dispatch_pending though so this doesn't help much.

- 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