Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
libuEv | Simple event loop for Linux
Introduction
libuEv is a simple event loop in the style of the more established libevent, libev and the venerable Xt(3) event loop. The u (micro) in the name refers to both the small feature set and the small size overhead impact of the library.
Experienced developers may appreciate that libuEv is built on top of modern Linux APIs: epoll, timerfd and signalfd.
“Event driven software improves concurrency” -- Dave Zarzycki, Apple
Example
The library documentation is available as a separate document.
#include <stdio.h>
#include <uev/uev.h>
static void cb(uev_t *w, void *arg, int events)
{
printf("Callback runs every other second.\n");
}
int main(void)
{
uev_t timer;
uev_ctx_t *ctx;
uev_init(&ctx);
uev_timer_init(&ctx, &timer, cb, NULL, 2 * 1000, 0);
return uev_run(&ctx, 0);
}
Build & Install
libuEv use the GNU configure and build system. To try out the bundled
examples, use the --enable-examples switch to the configure script.
There is also a limited unit test suite that can be useful to learn how
the library works.
$ ./configure
$ make -j5
$ make test
$ sudo make install-strip
$ sudo ldconfig
The resulting .so file is ~14 kiB.
Origin & References
libuEv was originally based on LibUEvent by Flemming Madsen but has been completely rewritten to provide a cleaner API. It is now more similar to the famous libev by Mark Lehmann. Another small event library used for inspiration is the very small picoev by Oku Kazuho.
libuEv is developed and maintained by Joachim Nilsson. It is built for and developed on GNU/Linux systems, patches to support *BSD and its kqueue interface are most welcome.
