From c3a3f33d0d4ad477f0b40f4ea649d6ac523a45fa Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 Dec 2007 16:49:49 +0000 Subject: *** empty log message *** --- ev.html | 58 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 10 deletions(-) (limited to 'ev.html') diff --git a/ev.html b/ev.html index d95bffd..81ff69b 100644 --- a/ev.html +++ b/ev.html @@ -6,7 +6,7 @@ - + @@ -335,7 +335,7 @@ a fork, you can also make libev check for a fork in each iteration by 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).

@@ -482,6 +482,15 @@ do not need to care.

Like ev_default_fork, but acts on an event loop created by 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)
@@ -771,6 +780,26 @@ libev (e.g. you cnanot free () it).

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 @@ was some error while stating the file.

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 @@ pseudo-code only of course:

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 ())); @@ -2084,6 +2116,12 @@ argument. Instead, all functions act on the single default loop.

If undefined or defined to be 1, then periodic timers are supported. If 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
-- cgit v1.2.3