--- libev/ev.html 2007/11/29 20:05:59 1.63 +++ libev/ev.html 2007/12/07 16:49:49 1.64 @@ -6,7 +6,7 @@ - + @@ -335,7 +335,7 @@ enabling this flag.

This works by calling getpid () 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 noticable (on my +iterations and little real work, but is usually not noticeable (on my Linux system for example, getpid is actually a simple 5-insn sequence without a syscall and thus very fast, but my Linux system also has pthread_atfork which is even faster).

@@ -483,6 +483,15 @@ ev_loop_new. Yes, you have to call this on every allocated event loop after fork, and how you do this is entirely your own problem.

+
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 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 +ev_prepare and ev_check calls.

+
unsigned int ev_backend (loop)

Returns one of the EVBACKEND_* flags indicating the event backend in @@ -771,6 +780,26 @@

Change the callback. You can change the callback at virtually any time (modulo threads).

+
ev_set_priority (ev_TYPE *watcher, priority)
+
int ev_priority (ev_TYPE *watcher)
+
+

Set and query the priority of the watcher. The priority is a small +integer between EV_MAXPRI (default: 2) and EV_MINPRI +(default: -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 ev_idle watchers).

+

This means that priorities are only 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 ev_idle watchers, which provide this functionality.

+

The default priority used by watchers when no priority has been set is +always 0, which is supposed to not be too high and not be too low :).

+

Setting a priority outside the range of EV_MINPRI to EV_MAXPRI 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.

+
@@ -1360,13 +1389,15 @@

ev_idle - 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.

Apart from keeping your process non-blocking (which is a useful @@ -1466,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 ())); @@ -2086,6 +2118,12 @@ defined to be 0, then they are not. Disabling them saves a few kB of code.

+
EV_IDLE_ENABLE
+
+

If undefined or defined to be 1, then idle watchers are supported. If +defined to be 0, then they are not. Disabling them saves a few kB of +code.

+
EV_EMBED_ENABLE

If undefined or defined to be 1, then embed watchers are supported. If