Closed agners closed 4 years ago
I've actually been working on a main loop library to go with neatvnc and wayvnc. Because it doesn't try to be super fast and use epoll/kqueue with io-threads and what not, it's super simple. It doesn't need to service many users for this application, so it can be simple. Also, one can define callbacks to handle fds, timers and signals.
It may sound a little silly to implement one's own event loop library, but the rationale here is that it'll be much simpler than the ones that try to be "the fastest event loop library in the west", so it should be easier to reason about and fix bugs.
I'll share my work with you.
Library looks neat :-)
From my perspective the most important feature would be to have support for integrating it into another event loop library. I am not 100% sure how that is usually implemented, I was always under the assumption that epoll is used for that? Do you have plans for this feature?
Well, things would actually be a lot simpler if I could just use epoll, but epoll isn't portable. That's why it must either be imitated using threads and poll()/select() or allow the user to register callbacks.
The main feature of this library is that it can be integrated with other event loops and in that case it should function as a thin abstraction layer on top. I was thinking that I might actually even include backends for the most common event loops in the code base. That way people wouldn't even have to write integration code when using the library.
Getting different event loops to play together nicely is a pain point for many developers. Maybe this library can be a toolkit for solving that problem.
The total list of goals should look something like this:
Non-goals:
The repo is now public. Here is an example of how the library can act as a wrapper around another event loop library: https://github.com/any1/aml/blob/master/examples/uv.c
There would be less integration code to write if I allowed myself to just use epoll
and kqueue
, but I will add built-in backends for that later, in which case the user might allow himself to be lazy and just use aml_get_fd()
.
Anyhow, the whole thing is only 1700 lines of code, whereas libuv is 39000 lines of code. I've a feeling that my little library should be much easier to debug. :)
I tried replacing libuv with aml here: https://github.com/any1/neatvnc/tree/aml wayvnc branch is here: https://github.com/any1/wayvnc/tree/aml
I might try creating a wl_event backend for aml tomorrow.
@agners, wayland-server integration example is here: https://github.com/any1/aml/blob/master/examples/wayland.c Now I just need to make it so that aml's thread pool can be used with event loops that don't have their own thread pool, and then you should be all set for further weston work.
Neat VNC now uses aml. To integrate with it, users should implement the appropriate event backend for aml. See example in prior comment.
Hi,
This implements support for external event loop as discussed in #16. It is somewhat rough and obviously breaks API, but seems to work with an adopted Weston VNC backend: https://gitlab.freedesktop.org/agners/weston/-/commits/rfc-vnc-support-with-neatvnc-wayland-event-loop