--- libev/ev.pod 2008/10/28 14:13:52 1.207 +++ libev/ev.pod 2008/10/30 08:09:30 1.210 @@ -300,7 +300,7 @@ Note that this function is I thread-safe, so if you want to use it from multiple threads, you have to lock (note also that this is unlikely, -as loops cannot bes hared easily between threads anyway). +as loops cannot be shared easily between threads anyway). The default loop is the only loop that can handle C and C watchers, and to do this, it always registers a handler @@ -388,27 +388,29 @@ like O(total_fds) where n is the total number of fds (or the highest fd), epoll scales either O(1) or O(active_fds). -The epoll syscalls are the most misdesigned of the more advanced event -mechanisms: problems include silently dropping fds, requiring a system -call per change per fd (and unnecessary guessing of parameters), problems -with dup and so on. The biggest issue is fork races, however - if a -program forks then I parent and child process have to recreate the -epoll set, which can take considerable time (one syscall per fd) and is of -course hard to detect. +The epoll mechanism deserves honorable mention as the most misdesigned +of the more advanced event mechanisms: mere annoyances include silently +dropping file descriptors, requiring a system call per change per file +descriptor (and unnecessary guessing of parameters), problems with dup and +so on. The biggest issue is fork races, however - if a program forks then +I parent and child process have to recreate the epoll set, which can +take considerable time (one syscall per file descriptor) and is of course +hard to detect. -Epoll is also notoriously buggy - embedding epoll fds should work, but -of course doesn't, and epoll just loves to report events for totally +Epoll is also notoriously buggy - embedding epoll fds I work, but +of course I, and epoll just loves to report events for totally I file descriptors (even already closed ones, so one cannot even remove them from the set) than registered in the set (especially on SMP systems). Libev tries to counter these spurious notifications by employing an additional generation counter and comparing that against the -events to filter out spurious ones. +events to filter out spurious ones, recreating the set when required. While stopping, setting and starting an I/O watcher in the same iteration -will result in some caching, there is still a system call per such incident -(because the fd could point to a different file description now), so its -best to avoid that. Also, C'ed file descriptors might not work -very well if you register events for both fds. +will result in some caching, there is still a system call per such +incident (because the same I could point to a different +I now), so its best to avoid that. Also, C'ed +file descriptors might not work very well if you register events for both +file descriptors. Best performance from this backend is achieved by not unregistering all watchers for a file descriptor until it has been closed, if possible, @@ -426,12 +428,15 @@ =item C (value 8, most BSD clones) -Kqueue deserves special mention, as at the time of this writing, it was -broken on all BSDs except NetBSD (usually it doesn't work reliably with -anything but sockets and pipes, except on Darwin, where of course it's -completely useless). For this reason it's not being "auto-detected" unless -you explicitly specify it in the flags (i.e. using C) or -libev was compiled on a known-to-be-good (-enough) system like NetBSD. +Kqueue deserves special mention, as at the time of this writing, it +was broken on all BSDs except NetBSD (usually it doesn't work reliably +with anything but sockets and pipes, except on Darwin, where of course +it's completely useless). Unlike epoll, however, whose brokenness +is by design, these kqueue bugs can (and eventually will) be fixed +without API changes to existing programs. For this reason it's not being +"auto-detected" unless you explicitly specify it in the flags (i.e. using +C) or libev was compiled on a known-to-be-good (-enough) +system like NetBSD. You still can embed kqueue into a normal poll or select backend and use it only for sockets (after having made sure that sockets work with kqueue on @@ -649,7 +654,7 @@ A flags value of C will look for new events (waiting if necessary) and will handle those and any already outstanding ones. It will block your process until at least one new event arrives (which could -be an event internal to libev itself, so there is no guarentee that a +be an event internal to libev itself, so there is no guarantee that a user-registered callback will be called), and will return after one iteration of the loop. @@ -1945,7 +1950,7 @@ recommended!) then a I value will be used (which you can expect to be around five seconds, although this might change dynamically). Libev will also impose a minimum interval which is -currently around C<0.1>, but thats usually overkill. +currently around C<0.1>, but that's usually overkill. This watcher type is not meant for massive numbers of stat watchers, as even with OS-supported change notifications, this can be @@ -2645,7 +2650,7 @@ =item ev_async_init (ev_async *, callback) Initialises and configures the async watcher - it has no parameters of any -kind. There is a C macro, but using it is utterly pointless, +kind. There is a C macro, but using it is utterly pointless, trust me. =item ev_async_send (loop, ev_async *) @@ -3088,7 +3093,7 @@ #include "ev.h" Both header files and implementation files can be compiled with a C++ -compiler (at least, thats a stated goal, and breakage will be treated +compiler (at least, that's a stated goal, and breakage will be treated as a bug). You need the following files in your source tree, or in a directory @@ -3570,7 +3575,7 @@ Care has been taken to ensure that libev does not keep local state inside C, and other calls do not usually allow for coroutine switches as -they do not clal any callbacks. +they do not call any callbacks. =head2 COMPILER WARNINGS @@ -3614,7 +3619,7 @@ ==2274== still reachable: 256 bytes in 1 blocks. Then there is no memory leak, just as memory accounted to global variables -is not a memleak - the memory is still being refernced, and didn't leak. +is not a memleak - the memory is still being referenced, and didn't leak. Similarly, under some circumstances, valgrind might report kernel bugs as if it were a bug in libev (e.g. in realloc or in the poll backend, @@ -3862,5 +3867,5 @@ =head1 AUTHOR -Marc Lehmann . +Marc Lehmann , with repeated corrections by Mikael Magnusson.