X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/ed54de67c9823483cc94f0decfd2f5405a5844f7..4bfa2139d1477eca27d2050ca93951cc409517ac:/ev.pod?ds=sidebyside diff --git a/ev.pod b/ev.pod index b98a930..2269dff 100644 --- a/ev.pod +++ b/ev.pod @@ -6,7 +6,7 @@ libev - a high performance full-featured event loop written in C #include -=head1 EXAMPLE PROGRAM +=head2 EXAMPLE PROGRAM #include @@ -67,7 +67,7 @@ watchers>, which are relatively small C structures you initialise with the details of the event, and then hand it over to libev by I the watcher. -=head1 FEATURES +=head2 FEATURES Libev supports C which have a high +overhead for the actual polling but can deliver many events at once. + +By setting a higher I you allow libev to spend more +time collecting I/O events, so you can handle more events per iteration, +at the cost of increasing latency. Timeouts (both C and +C) will be not affected. Setting this to a non-null value will +introduce an additional C call into most loop iterations. + +Likewise, by setting a higher I you allow libev +to spend more time collecting timeouts, at the expense of increased +latency (the watcher callback will be called later). C watchers +will not be affected. Setting this to a non-null value will not introduce +any overhead in libev. + +Many (busy) programs can usually benefit by setting the io collect +interval to a value near C<0.1> or so, which is often enough for +interactive servers (of course not for games), likewise for timeouts. It +usually doesn't make much sense to set it to a lower value than C<0.01>, +as this approsaches the timing granularity of most systems. + =back @@ -951,15 +1031,15 @@ This is how one would do it normally anyway, the important point is that the libev application should not optimise around libev but should leave optimisations to libev. -=head3 Ths special problem of dup'ed file descriptors +=head3 The special problem of dup'ed file descriptors Some backends (e.g. epoll), cannot register events for file descriptors, -but only events for the underlying file descriptions. That menas when you +but only events for the underlying file descriptions. That means when you have C'ed file descriptors and register events for them, only one file descriptor might actually receive events. -There is no workaorund possible except not registering events -for potentially C'ed file descriptors or to resort to +There is no workaround possible except not registering events +for potentially C'ed file descriptors, or to resort to C or C. =head3 The special problem of fork @@ -1583,11 +1663,11 @@ It is recommended to give C watchers highest (C) priority, to ensure that they are being run before any other watchers after the poll. Also, C watchers (and C watchers, too) should not activate ("feed") events into libev. While libev fully -supports this, they will be called before other C watchers did -their job. As C watchers are often used to embed other event -loops those other event loops might be in an unusable state until their -C watcher ran (always remind yourself to coexist peacefully with -others). +supports this, they will be called before other C watchers +did their job. As C watchers are often used to embed other +(non-libev) event loops those other event loops might be in an unusable +state until their C watcher ran (always remind yourself to +coexist peacefully with others). =head3 Watcher-Specific Functions and Data Members @@ -1736,7 +1816,7 @@ this. This is a rather advanced watcher type that lets you embed one event loop into another (currently only C events are supported in the embedded loop, other types of watchers might be handled in a delayed or incorrect -fashion and must not be used). (See portability notes, below). +fashion and must not be used). There are primarily two reasons you would want that: work around bugs and prioritise I/O. @@ -1801,22 +1881,6 @@ create it, and if that fails, use the normal loop for everything: else loop_lo = loop_hi; -=head2 Portability notes - -Kqueue is nominally embeddable, but this is broken on all BSDs that I -tried, in various ways. Usually the embedded event loop will simply never -receive events, sometimes it will only trigger a few times, sometimes in a -loop. Epoll is also nominally embeddable, but many Linux kernel versions -will always eport the epoll fd as ready, even when no events are pending. - -While libev allows embedding these backends (they are contained in -C), take extreme care that it will actually -work. - -When in doubt, create a dynamic event loop forced to use sockets (this -usually works) and possibly another thread and a pipe or so to report to -your main event loop. - =head3 Watcher-Specific Functions and Data Members =over 4 @@ -2299,6 +2363,11 @@ be attempted. This effectively replaces C by C and will not normally affect correctness. See the note about libraries in the description of C, though. +=item EV_USE_NANOSLEEP + +If defined to be C<1>, libev will assume that C is available +and will use it for delays. Otherwise it will use C