1 | libev is modelled after libevent (http://monkey.org/~provos/libevent/), but aims |
1 | Homepage: http://software.schmorp.de/pkg/libev |
2 | to be faster and more correct, and also more featureful. Examples: |
2 | E-Mail: libev@schmorp.de |
3 | |
3 | |
|
|
4 | libev is a high-performance event loop/event model with lots of features. |
|
|
5 | |
|
|
6 | It is modelled (very losely) after libevent |
|
|
7 | (http://monkey.org/~provos/libevent/) and the Event perl module, but aims |
|
|
8 | to be faster and more correct, and also more featureful. |
|
|
9 | |
|
|
10 | DIFFERENCES AND COMPARISON TO LIBEVENT: |
|
|
11 | |
|
|
12 | (comparisons relative to libevent-1.3e and libev-0.00, see also the benchmark |
|
|
13 | at http://libev.schmorp.de/bench.html). |
|
|
14 | |
4 | - multiple watchers can wait for the same event without deregistering others. |
15 | - multiple watchers can wait for the same event without deregistering others, |
|
|
16 | both for file descriptors as well as signals. |
5 | (registering two read events on fd 10 and unregistering one will not |
17 | (registering two read events on fd 10 and unregistering one will not |
6 | break the other) |
18 | break the other). |
7 | |
19 | |
8 | - fork() is supported and can be handled |
20 | - fork() is supported and can be handled |
9 | (there is no way to recover from a fork when libevent is active) |
21 | (there is no way to recover from a fork when libevent is active). |
10 | |
22 | |
11 | - timers are handled as a priority queue |
23 | - timers are handled as a priority queue (important operations are O(1)) |
12 | (libevent uses a less efficient red-black tree) |
24 | (libevent uses a much less efficient but more complex red-black tree). |
13 | |
25 | |
14 | - supports absolute (wallclock-based) timers in addition to relative ones, |
26 | - supports absolute (wallclock-based) timers in addition to relative ones, |
15 | i.e. can schedule timers to occur after n seconds, or at a specific time. |
27 | i.e. can schedule timers to occur after n seconds, or at a specific time. |
16 | |
28 | |
17 | - timers can be repeating (both absolute and relative ones) |
29 | - timers can be repeating (both absolute and relative ones). |
18 | |
30 | |
19 | - detects time jumps and adjusts timers |
31 | - detects time jumps and adjusts timers |
20 | (works for both forward and backward time jumps and also for absolute timers) |
32 | (works for both forward and backward time jumps and also for absolute timers). |
21 | |
33 | |
22 | - can correctly remove timers while executing callbacks |
34 | - race-free signal processing |
23 | (libevent doesn't handle this reliably and can crash) |
35 | (libevent may delay processing signals till after the next event). |
24 | |
36 | |
25 | - less calls to epoll_ctl |
37 | - less calls to epoll_ctl |
26 | (stopping and starting an io watcher between two loop iterations will now |
38 | (stopping and starting an io watcher between two loop iterations will now |
27 | result in spuriois epoll_ctl calls) |
39 | result in spuriois epoll_ctl calls). |
28 | |
40 | |
29 | - usually less calls to gettimeofday and clock_gettime |
41 | - usually less calls to gettimeofday and clock_gettime |
30 | (libevent calls it on every timer event change, libev twice per iteration) |
42 | (libevent calls it on every timer event change, libev twice per iteration). |
31 | |
43 | |
32 | - watchers use less memory |
44 | - watchers use less memory |
33 | (libevent on amd64: 152 bytes, libev: <= 56 bytes) |
45 | (libevent on amd64: 152 bytes, libev: <= 56 bytes). |
34 | |
46 | |
35 | - library uses less memory |
47 | - library uses less memory |
36 | (libevent allocates large data structures wether used or not, libev |
48 | (libevent allocates large data structures wether used or not, libev |
37 | scales all its data structures dynamically) |
49 | scales all its data structures dynamically). |
38 | |
50 | |
39 | - no hardcoded arbitrary limits |
51 | - no hardcoded arbitrary limits |
40 | (libevent contains an off-by-one bug and sometimes hardcodes a limit of |
52 | (libevent contains an off-by-one bug and sometimes hardcodes a limit of |
41 | 32000 fds) |
53 | 32000 fds). |
42 | |
54 | |
43 | - libev separates timer, signal and io watchers from each other |
55 | - libev separates timer, signal and io watchers from each other |
44 | (libevent combines them, but with libev you can combine them yourself |
56 | (libevent combines them, but with libev you can combine them yourself |
45 | by reusing the same callback and still save memory) |
57 | by reusing the same callback and still save memory). |
46 | |
58 | |
47 | - simpler design, backends are potentially much simpler |
59 | - simpler design, backends are potentially much simpler |
48 | (in libevent, backends have to deal with watchers, thus the problems) |
60 | (in libevent, backends have to deal with watchers, thus the problems) |
49 | (epoll backend in libevent: 366 lines, libev: 89 lines, and more features) |
61 | (epoll backend in libevent: 366 lines, libev: 90 lines, and more features). |
|
|
62 | |
|
|
63 | - libev handles EBADF gracefully by removing the offending fds. |
|
|
64 | |
|
|
65 | - doesn't rely on nonportable BSD header files. |
|
|
66 | |
|
|
67 | - a event.h compatibility header exists, and can be used to run a wide |
|
|
68 | range of libevent programs unchanged (such as evdns.c). |
|
|
69 | |
|
|
70 | - win32 compatibility for the core parts. |
|
|
71 | |
|
|
72 | - the event core library (ev and event layer) compiles and works both as |
|
|
73 | C and C++. |
50 | |
74 | |
51 | whats missing? |
75 | whats missing? |
52 | |
76 | |
53 | - evdns, evhttp, bufferevent are missing, libev is only an even library at |
77 | - no event-like priority support at the moment (the ev priorities |
54 | the moment. |
78 | are not yet finished and work differently, but you can use idle watchers |
|
|
79 | to get a similar effect). |
55 | |
80 | |
56 | - no priority support at the moment. |
81 | AUTHOR |
57 | |
82 | |
58 | - kqueue, poll (libev currently implements epoll and select). |
83 | libev was written and designed by Marc Lehmann and Emanuele Giaquinta. |
59 | |
84 | |
|
|
85 | The following people sent in patches or made other noteworthy |
|
|
86 | contributions (if I forgot to include you, please shout at me, it was an |
|
|
87 | accident): |
|
|
88 | |
|
|
89 | W.C.A. Wijngaards |
|
|
90 | Christopher Layne |
|
|
91 | Chris Brody |
|
|
92 | |