--- libev/ev.pod 2019/03/18 19:28:15 1.446 +++ libev/ev.pod 2019/06/22 16:25:53 1.447 @@ -107,10 +107,10 @@ =head2 FEATURES -Libev supports C, C, the Linux-specific aio and C +interfaces, the BSD-specific C and the Solaris-specific event port +mechanisms for file descriptor events (C), the Linux C +interface (for C), Linux eventfd/signalfd (for faster and cleaner inter-thread wakeup (C)/signal handling (C)) relative timers (C), absolute timers with customised rescheduling (C), synchronous signals (C), process status @@ -569,7 +569,40 @@ the usage. So sad. While nominally embeddable in other event loops, this feature is broken in -all kernel versions tested so far. +a lot of kernel revisions, but probably(!) works in current versions. + +This backend maps C and C in the same way as +C. + +=item C (value 64, Linux) + +Use the linux-specific linux aio (I C<< aio(7) >>) event interface +available in post-4.18 kernels. + +If this backend works for you (as of this writing, it was very +experimental and only supports a subset of file types), it is the best +event interface available on linux and might be well worth it enabling it +- if it isn't available in your kernel this will be detected and another +backend will be chosen. + +This backend can batch oneshot requests and uses a user-space ring buffer +to receive events. It also doesn't suffer from most of the design problems +of epoll (such as not being able to remove event sources from the epoll +set), and generally sounds too good to be true. Because, this being the +linux kernel, of course it suffers from a whole new set of limitations. + +For one, it is not easily embeddable (but probably could be done using +an event fd at some extra overhead). It also is subject to various +arbitrary limits that can be configured in F +and F), which could lead to it being skipped during +initialisation. + +Most problematic in practise, however, is that, like kqueue, it requires +special support from drivers, and, not surprisingly, not all drivers +implement it. For example, in linux 4.19, tcp sockets, pipes, event fds, +files, F and a few others are supported, but ttys are not, so +this is not (yet?) a generic event polling interface but is probably still +be very useful in a web server or similar program. This backend maps C and C in the same way as C. @@ -680,6 +713,12 @@ struct ev_loop *loop = ev_loop_new (ev_recommended_backends () | EVBACKEND_KQUEUE); +Example: Similarly, on linux, you mgiht want to take advantage of the +linux aio backend if possible, but fall back to something else if that +isn't available. + + struct ev_loop *loop = ev_loop_new (ev_recommended_backends () | EVBACKEND_LINUXAIO); + =item ev_loop_destroy (loop) Destroys an event loop object (frees all memory and kernel state @@ -1632,13 +1671,13 @@ =head3 The special problem of disappearing file descriptors -Some backends (e.g. kqueue, epoll) need to be told about closing a file -descriptor (either due to calling C explicitly or any other means, -such as C). The reason is that you register interest in some file -descriptor, but when it goes away, the operating system will silently drop -this interest. If another file descriptor with the same number then is -registered with libev, there is no efficient way to see that this is, in -fact, a different file descriptor. +Some backends (e.g. kqueue, epoll, linuxaio) need to be told about closing +a file descriptor (either due to calling C explicitly or any other +means, such as C). The reason is that you register interest in some +file descriptor, but when it goes away, the operating system will silently +drop this interest. If another file descriptor with the same number then +is registered with libev, there is no efficient way to see that this is, +in fact, a different file descriptor. To avoid having to explicitly tell libev about such cases, libev follows the following policy: Each time C is being called, libev @@ -1697,9 +1736,10 @@ =head3 The special problem of fork -Some backends (epoll, kqueue) do not support C at all or exhibit -useless behaviour. Libev fully supports fork, but needs to be told about -it in the child if you want to continue to use it in the child. +Some backends (epoll, kqueue, probably linuxaio) do not support C +at all or exhibit useless behaviour. Libev fully supports fork, but needs +to be told about it in the child if you want to continue to use it in the +child. To support fork in your child processes, you have to call C after a fork in the child, enable C, or resort to @@ -4430,6 +4470,7 @@ ev_select.c only when select backend is enabled ev_poll.c only when poll backend is enabled ev_epoll.c only when the epoll backend is enabled + ev_linuxaio.c only when the linux aio backend is enabled ev_kqueue.c only when the kqueue backend is enabled ev_port.c only when the solaris port backend is enabled @@ -4630,6 +4671,13 @@ backend for GNU/Linux systems. If undefined, it will be enabled if the headers indicate GNU/Linux + Glibc 2.4 or newer, otherwise disabled. +=item EV_USE_LINUXAIO + +If defined to be C<1>, libev will compile in support for the Linux +aio backend. Due to it's currenbt limitations it has to be requested +explicitly. If undefined, it will be enabled on linux, otherwise +disabled. + =item EV_USE_KQUEUE If defined to be C<1>, libev will compile in support for the BSD style