--- libev/ev.pod 2007/11/28 17:32:24 1.59 +++ libev/ev.pod 2007/12/07 16:44:12 1.67 @@ -268,6 +268,26 @@ useful to try out specific backends to test their performance, or to work around bugs. +=item C + +Instead of calling C or C manually after +a fork, you can also make libev check for a fork in each iteration by +enabling this flag. + +This works by calling C on every iteration of the loop, +and thus this might slow down your event loop if you do a lot of loop +iterations and little real work, but is usually not noticeable (on my +Linux system for example, C is actually a simple 5-insn sequence +without a syscall and thus I fast, but my Linux system also has +C which is even faster). + +The big advantage of this flag is that you can forget about fork (and +forget about forgetting to tell libev about forking) when you use this +flag. + +This flag setting cannot be overriden or specified in the C +environment variable. + =item C (value 1, portable select backend) This is your standard select(2) backend. Not I standard, as @@ -412,6 +432,16 @@ C. Yes, you have to call this on every allocated event loop after fork, and how you do this is entirely your own problem. +=item unsigned int ev_loop_count (loop) + +Returns the count of loop iterations for the loop, which is identical to +the number of times libev did poll for new events. It starts at C<0> and +happily wraps around with enough iterations. + +This value can sometimes be useful as a generation counter of sorts (it +"ticks" the number of loop iterations), as it roughly corresponds with +C and C calls. + =item unsigned int ev_backend (loop) Returns one of the C flags indicating the event backend in @@ -716,6 +746,31 @@ Change the callback. You can change the callback at virtually any time (modulo threads). +=item ev_set_priority (ev_TYPE *watcher, priority) + +=item int ev_priority (ev_TYPE *watcher) + +Set and query the priority of the watcher. The priority is a small +integer between C (default: C<2>) and C +(default: C<-2>). Pending watchers with higher priority will be invoked +before watchers with lower priority, but priority will not keep watchers +from being executed (except for C watchers). + +This means that priorities are I used for ordering callback +invocation after new events have been received. This is useful, for +example, to reduce latency after idling, or more often, to bind two +watchers on the same event and make sure one is called first. + +If you need to suppress invocation when higher priority events are pending +you need to look at C watchers, which provide this functionality. + +The default priority used by watchers when no priority has been set is +always C<0>, which is supposed to not be too high and not be too low :). + +Setting a priority outside the range of C to C is +fine, as long as you do not mind that the priority value you query might +or might not have been adjusted to be within valid range. + =back @@ -918,23 +973,25 @@ This will act as if the timer timed out and restart it again if it is repeating. The exact semantics are: -If the timer is started but nonrepeating, stop it. +If the timer is pending, its pending status is cleared. -If the timer is repeating, either start it if necessary (with the repeat -value), or reset the running timer to the repeat value. +If the timer is started but nonrepeating, stop it (as if it timed out). + +If the timer is repeating, either start it if necessary (with the +C value), or reset the running timer to the C value. This sounds a bit complicated, but here is a useful and typical -example: Imagine you have a tcp connection and you want a so-called -idle timeout, that is, you want to be called when there have been, -say, 60 seconds of inactivity on the socket. The easiest way to do -this is to configure an C with C=C=C<60> and calling +example: Imagine you have a tcp connection and you want a so-called idle +timeout, that is, you want to be called when there have been, say, 60 +seconds of inactivity on the socket. The easiest way to do this is to +configure an C with a C value of C<60> and then call C each time you successfully read or write some data. If you go into an idle state where you do not expect data to travel on the -socket, you can stop the timer, and again will automatically restart it if -need be. +socket, you can C the timer, and C will +automatically restart it if need be. -You can also ignore the C value and C altogether -and only ever use the C value: +That means you can ignore the C value and C +altogether and only ever use the C value and C: ev_timer_init (timer, callback, 0., 5.); ev_timer_again (loop, timer); @@ -945,8 +1002,8 @@ timer->again = 10.; ev_timer_again (loop, timer); -This is more efficient then stopping/starting the timer eahc time you want -to modify its timeout value. +This is more slightly efficient then stopping/starting the timer each time +you want to modify its timeout value. =item ev_tstamp repeat [read-write] @@ -1225,6 +1282,9 @@ otherwise always forced to be at least one) and all the other fields of the stat buffer having unspecified contents. +The path I be absolute and I end in a slash. If it is +relative and your working directory changes, the behaviour is undefined. + Since there is no standard to do this, the portable implementation simply calls C regularly on the path to see if it changed somehow. You can specify a recommended polling interval for this case. If you specify @@ -1318,13 +1378,16 @@ =head2 C - when you've got nothing better to do... -Idle watchers trigger events when there are no other events are pending -(prepare, check and other idle watchers do not count). That is, as long -as your process is busy handling sockets or timeouts (or even signals, -imagine) it will not be triggered. But when your process is idle all idle -watchers are being called again and again, once per event loop iteration - -until stopped, that is, or your process receives more events and becomes -busy. +Idle watchers trigger events when no other events of the same or higher +priority are pending (prepare, check and other idle watchers do not +count). + +That is, as long as your process is busy handling sockets or timeouts +(or even signals, imagine) of the same or higher priority it will not be +triggered. But when your process is idle (or only lower-priority watchers +are pending), the idle watchers are being called once per event loop +iteration - until stopped, that is, or your process receives more events +and becomes busy again with higher priority stuff. The most noteworthy effect is that as long as any idle watchers are active, the process will not block when waiting for new events. @@ -1434,7 +1497,8 @@ static void adns_prepare_cb (ev_loop *loop, ev_prepare *w, int revents) { - int timeout = 3600000;truct pollfd fds [nfd]; + int timeout = 3600000; + struct pollfd fds [nfd]; // actual code will need to loop here and realloc etc. adns_beforepoll (ads, fds, &nfd, &timeout, timeval_from (ev_time ())); @@ -1825,8 +1889,9 @@ =back -Example: Declare and initialise a check watcher, working regardless of -wether multiple loops are supported or not. +Example: Declare and initialise a check watcher, utilising the above +macros so it will work regardless of wether multiple loops are supported +or not. static void check_cb (EV_P_ ev_timer *w, int revents) @@ -1839,7 +1904,6 @@ ev_check_start (EV_DEFAULT_ &check); ev_loop (EV_DEFAULT_ 0); - =head1 EMBEDDING Libev can (and often is) directly embedded into host @@ -1888,7 +1952,7 @@ ev_win32.c required on win32 platforms only - ev_select.c only when select backend is enabled (which is by default) + ev_select.c only when select backend is enabled (which is enabled by default) ev_poll.c only when poll backend is enabled (disabled by default) ev_epoll.c only when the epoll backend is enabled (disabled by default) ev_kqueue.c only when the kqueue backend is enabled (disabled by default) @@ -2067,6 +2131,12 @@ defined to be C<0>, then they are not. Disabling them saves a few kB of code. +=item EV_IDLE_ENABLE + +If undefined or defined to be C<1>, then idle watchers are supported. If +defined to be C<0>, then they are not. Disabling them saves a few kB of +code. + =item EV_EMBED_ENABLE If undefined or defined to be C<1>, then embed watchers are supported. If @@ -2140,12 +2210,17 @@ file. The usage in rxvt-unicode is simpler. It has a F header file -that everybody includes and which overrides some autoconf choices: +that everybody includes and which overrides some configure choices: + #define EV_MINIMAL 1 #define EV_USE_POLL 0 #define EV_MULTIPLICITY 0 - #define EV_PERIODICS 0 + #define EV_PERIODIC_ENABLE 0 + #define EV_STAT_ENABLE 0 + #define EV_FORK_ENABLE 0 #define EV_CONFIG_H + #define EV_MINPRI 0 + #define EV_MAXPRI 0 #include "ev++.h"