Simplify ingress, example and origin

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2019-04-06 12:23:48 +02:00
1 parent 38858488b9
commit d4096c8c0c
1 file changed
+37 -32
+37 -32
View File
@@ -1,5 +1,5 @@
libuEv | Simple event loop for Linux µEv | Simple event loop for Linux
==================================== ==================================
[![Travis Status][]][Travis] [![Coverity Status][]][Coverity Scan] [![Travis Status][]][Travis] [![Coverity Status][]][Coverity Scan]
@@ -20,10 +20,10 @@ libuEv | Simple event loop for Linux
Introduction Introduction
------------ ------------
[libuEv][] is a simple event loop in the style of the more established [libuEv][] is a small event loop that wraps the Linux `epoll()` family
[libevent][1], [libev][2] and the venerable [Xt(3)][3] event loop. The of APIs. It is similar to the more established [libevent][], [libev][]
*u* (micro) in the name refers to both the small feature set and the and the venerable [Xt(3)][] event loop. The *µ* in the name refers to
small size overhead impact of the library. both its limited feature set and the size impact of the library.
Failure mode changes introduced in v2.0 may affect users of v1.x, See Failure mode changes introduced in v2.0 may affect users of v1.x, See
the [ChangeLog][] for the full details. the [ChangeLog][] for the full details.
@@ -34,34 +34,35 @@ The [API documentation](API.md) is available as a separate document.
Example Example
------- -------
Notice below how watcher `UEV_ERROR` conditions must be handled by each Notice how watcher conditions like `UEV_ERROR` must be handled by each
callback. I/O watchers must also check for `UEV_HUP`. Both errors are callback. I/O watchers must also check for `UEV_HUP`. Both errors are
usually fatal, libuEv makes sure to stop each watcher before a callback usually fatal, libuEv makes sure to stop each watcher before a callback
runs, leaving it up to the callback to take appropriate action. runs, leaving it up to the callback to take appropriate action.
```C ```C
/* Set up a timer watcher to call cb() every other second */
#include <stdio.h> #include <stdio.h>
#include <uev/uev.h> #include <uev/uev.h>
static void cb(uev_t *w, void *arg, int events) static void cb(uev_t *w, void *arg, int events)
{ {
if (UEV_ERROR == events) { if (UEV_ERROR == events) {
puts("Problem with timer, attempting to restart."); puts("Problem with timer, attempting to restart.");
uev_timer_start(w); uev_timer_start(w);
} }
puts("Every other second");
puts("Every other second");
} }
int main(void) int main(void)
{ {
uev_t timer; uev_ctx_t ctx;
uev_ctx_t ctx; uev_t timer;
uev_init(&ctx); uev_init(&ctx);
/* Set up a timer watcher to call cb() every other second */ uev_timer_init(&ctx, &timer, cb, NULL, 2 * 1000, 2 * 1000);
uev_timer_init(&ctx, &timer, cb, NULL, 2 * 1000, 2 * 1000);
return uev_run(&ctx, 0); return uev_run(&ctx, 0);
} }
``` ```
@@ -82,36 +83,40 @@ sudo make install-strip
sudo ldconfig sudo ldconfig
``` ```
The resulting .so file is ~14 kiB. The resulting .so library is ~23 kiB.
To build from GIT sources; clone the repository and run the `autogen.sh`
script. This requires GNU `automake`, `autoconf` amd `libtool` to be
installed on your system. (If you build from a released tarball you do
not need them.)
Origin & References Origin & References
------------------- -------------------
[libuEv][] originates from [LibUEvent][8] by [Flemming Madsen][], but [libuEv][] is developed and maintained by [Joachim Nilsson][] on GitHub.
with a rewritten and much cleaner API. It is now more similar to the It is primarily built for and developed on GNU/Linux systems, patches to
famous [libev][2] by [Mark Lehmann][]. Another library inspiring this support the BSD [kqueue][] interface are most welcome.
project is [picoev][9] by [Oku Kazuho][].
[libuEv][] is developed and maintained by [Joachim Nilsson][]. It is Originally based on [LibUEvent][] by [Flemming Madsen][], uEv has since
built for and developed on GNU/Linux systems, patches to support *BSD evolved to support all of the Linux `epoll()` family APIs. It is now
and its [kqueue][] interface are most welcome. more similar to the excellent [libev][] by [Mark Lehmann][], with some
inspiration also from [picoev][] by [Oku Kazuho][].
[1]: http://libevent.org
[2]: http://software.schmorp.de/pkg/libev.html
[3]: http://unix.com/man-page/All/3x/XtDispatchEvent
[8]: http://code.google.com/p/libuevent/
[9]: https://github.com/kazuho/picoev
[ChangeLog]: https://github.com/troglobit/libuev/blob/master/ChangeLog.md [ChangeLog]: https://github.com/troglobit/libuev/blob/master/ChangeLog.md
[Travis]: https://travis-ci.org/troglobit/libuev [Travis]: https://travis-ci.org/troglobit/libuev
[Travis Status]: https://travis-ci.org/troglobit/libuev.png?branch=master [Travis Status]: https://travis-ci.org/troglobit/libuev.png?branch=master
[Coverity Scan]: https://scan.coverity.com/projects/3846 [Coverity Scan]: https://scan.coverity.com/projects/3846
[Coverity Status]: https://scan.coverity.com/projects/3846/badge.svg [Coverity Status]: https://scan.coverity.com/projects/3846/badge.svg
[libevent]: https://libevent.org
[Xt(3)]: https://unix.com/man-page/All/3x/XtDispatchEvent
[LibUEvent]: https://code.google.com/p/libuevent/
[picoev]: https://github.com/kazuho/picoev
[libev]: http://software.schmorp.de/pkg/libev.html
[LibuEv]: https://github.com/troglobit/libuev [LibuEv]: https://github.com/troglobit/libuev
[kqueue]: https://github.com/mheily/libkqueue [kqueue]: https://github.com/mheily/libkqueue
[Oku Kazuho]: https://github.com/kazuho [Oku Kazuho]: https://github.com/kazuho
[Mark Lehmann]: http://software.schmorp.de [Mark Lehmann]: http://software.schmorp.de
[Joachim Nilsson]: http://troglobit.com [Joachim Nilsson]: http://troglobit.com
[Flemming Madsen]: http://www.madsensoft.dk [Flemming Madsen]: http://www.madsensoft.dk
[Dave Zarzycki, Apple]: http://www.youtube.com/watch?v=cD_s6Fjdri8