[PATCH] event-loop: Only read one epoll event per loop dispatch.

Bill Spitzak spitzak at gmail.com
Tue Mar 20 10:39:18 PDT 2012


I may not be understanding the problem, or maybe my assumption that the 
destruction of a "source" is not under Wayland's control.

My opinion is that "deferred deletion" is a bad idea. There may be other 
objects being destroyed that destroy the source, and they rely on the 
source actually disappearing. What happens then is you have to defer the 
deletion of these objects as well. Eventually *everything* has to have a 
deferred deletion ability. Look at Qt if you don't believe me.

I seem to be having a hard time describing this. Here is what I would do:

   source* table[MAXENTRIES]; // I'll ignore overflow of this for now
   int nextentry;

   add(source* s) {
     int n = nextentry++;
     s->entry = n;
     table[n] = s;
     ep.data.int = n;
     epoll_ctl(...ep);
   }

   remove(source* s) {
     table[s->entry] = 0;
     epoll_ctl(...);
   }

   wl_event_loop_dispatch() {
     epoll(...);
     for (i=0; i < count; i++) {
       source = table[ep[i].data.int];
       if (source) source->interface->dispatch(source, &ep[i]);
     }
   }


More information about the wayland-devel mailing list