Joachim Nilsson 2f9cce9150 Do NOT exit event loop on timer/signal watcher error
This patch fixes a blocking issue discovered in the Finit project.
At shutdown, or when there is any problem with a timer or signal
watcher, the event loop is abruptly terminated.

Instead of unconditionally exiting the event loop on problems with a
single watcher, invalidate the watcher and run the callback one last
time with UEV_ERROR in the events argument.

This is a semantic change wrt. watchers and their callbacks, so the
major version number will be bumped accordingly to signal the severity
of this change.  From now on it is STRONGLY recommended that each call
back function check for UEV_ERROR.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-10 22:18:40 +01:00
2017-09-21 21:29:56 +02:00
2017-10-22 11:16:10 +02:00
2017-10-21 18:47:31 +02:00
2016-11-22 01:33:17 +01:00
2017-09-22 16:26:02 +02:00
2017-09-22 08:01:04 +02:00
2017-09-19 09:09:29 +02:00
2017-09-21 21:29:21 +02:00
2017-10-21 20:51:08 +02:00
2017-05-01 12:29:37 +02:00

libuEv | Simple event loop for Linux

Travis Status Coverity Status

“Event driven software improves concurrency” -- Dave Zarzycki, Apple

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.

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)
{
	puts("Every other second");
}

int main(void)
{
	uev_t timer;
	uev_ctx_t ctx;

	uev_init(&ctx);
	/* Set up a timer watcher to call cb() every other second */
	uev_timer_init(&ctx, &timer, cb, NULL, 0, 2 * 1000);

	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 originates from LibUEvent by Flemming Madsen, but with a rewritten and much cleaner API. It is now more similar to the famous libev by Mark Lehmann. Another library inspiring this project is 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.

S
Description
Lightweight event loop library for Linux epoll() family APIs
Readme MIT
951 KiB
Languages
C 71.5%
M4 25%
Makefile 3.4%