The future of event-loop
Overview
Supporting non-Linux platforms in Wayland currently requires the use of epoll-shim or a kqueue backend. Further, the event loop is used at a very basic capacity inside of Wayland itself, but downstream users rely on its functionality.
Maintaining it is an issue, and adding another backend just piles onto the work.
Options
-
Replace epoll backend with an event loop abstraction library like libuv or libev
- Con: Adds a dependency, but both are already packaged by all package managers for e.g. Node.js
- Con: May be challenging to emulate the current event loop's behaviour with a library
- Pro: Multitude of platform support that we don't have to maintain
-
Deprecate the event loop
- Pro: BSD support is much easier. No need to port an event loop, it will just be a linker error and the dependent is updated
- Pro: We don't have to maintain any event loop at all
- Con: All downstream programs need to update to use their own event loop
Replacing epoll backend
libuv looks like a real candidate and is packaged almost everywhere already as it is used by Node.js. The main issue is making sure that we remain ABI compatible and dispatch events in the same order as is done in the epoll backend.
See: http://docs.libuv.org/en/v1.x/design.html#the-i-o-loop. It looks like the only thing out of order is that we call idle callbacks before timers, whereas libuv has timers before everything else. Is this a real issue or can we safely replace with libuv without any tricky hacks?
I am not familiar with nor have looked at any other libraries like libev.