X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/4d842bfffe9d21022fb0e6ea51d3a5eedb39e69e..23f1f160c09151cb6c70284144b71915a0b1a4ef:/ev.html?ds=inline diff --git a/ev.html b/ev.html index 5fa8652..9739c2d 100644 --- a/ev.html +++ b/ev.html @@ -6,7 +6,7 @@ - +
@@ -57,7 +57,7 @@Libev is an event loop: you register interest in certain events (such as a file descriptor being readable or a timeout occuring), and it will manage -these event sources and provide your program events.
+these event sources and provide your program with events.To do this, it must take more or less complete control over your process (or thread) by executing the event loop handler, and will then communicate events via a callback mechanism.
@@ -73,14 +73,16 @@ watcher. kqueue mechanisms for file descriptor events, relative timers, absolute timers with customised rescheduling, signal events, process status change events (related to SIGCHLD), and event watchers dealing with the event -loop mechanism itself (idle, prepare and check watchers). +loop mechanism itself (idle, prepare and check watchers). It also is quite +fast (see this benchmark comparing +it to libevent for example).Libev is very configurable. In this manual the default configuration
will be described, which supports multiple event loops. For more info
-about various configuraiton options please have a look at the file
+about various configuration options please have a look at the file
README.embed in the libev distribution. If libev was configured without
support for multiple event loops, then all functions taking an initial
argument of name loop
(which is always of type struct ev_loop *
)
@@ -115,10 +117,10 @@ not a problem.
Sets the allocation function to use (the prototype is similar to the -realloc function). It is used to allocate and free memory (no surprises -here). If it returns zero when memory needs to be allocated, the library -might abort or take some potentially destructive action. The default is -your system realloc function.
+realloc C function, the semantics are identical). It is used to allocate +and free memory (no surprises here). If it returns zero when memory +needs to be allocated, the library might abort or take some potentially +destructive action. The default is your system realloc function.You could override this function in high-availability programs to, say, free some memory if it cannot allocate memory, to use a special allocator, or even to sleep a while and retry until some memory is available.
@@ -129,7 +131,7 @@ or even to sleep a while and retry until some memory is available. as failed select, poll, epoll_wait). The message is a printable string indicating the system call or subsystem causing the problem. If this callback is set, then libev will expect it to remedy the sitution, no -matter what, when it returns. That is, libev will geenrally retry the +matter what, when it returns. That is, libev will generally retry the requested operation, or, if the condition doesn't go away, do bad stuff (such as abort).If you use threads, a common model is to run the default event loop in your main thread (or in a separate thrad) and for each thread you -create, you also create another event loop. Libev itself does no lockign -whatsoever, so if you mix calls to different event loops, make sure you -lock (this is usually a bad idea, though, even if done right).
+create, you also create another event loop. Libev itself does no locking +whatsoever, so if you mix calls to the same event loop in different +threads, make sure you lock (this is usually a bad idea, though, even if +done correctly, because its hideous and inefficient).ev_<type>_stop (loop, watcher *)
As long as your watcher is active (has been started but not stopped) you must not touch the values stored in it. Most specifically you must never reinitialise it or call its set method.
-You cna check wether an event is active by calling the ev_is_active
-(watcher *)
macro. To see wether an event is outstanding (but the
+
You cna check whether an event is active by calling the ev_is_active
+(watcher *)
macro. To see whether an event is outstanding (but the
callback for it has not been called yet) you cna use the ev_is_pending
(watcher *)
macro.
Each and every callback receives the event loop pointer as first, the @@ -424,7 +427,7 @@ information given in the last section.
I/O watchers check wether a file descriptor is readable or writable +
I/O watchers check whether a file descriptor is readable or writable in each iteration of the event loop (This behaviour is called level-triggering because you keep receiving events as long as the condition persists. Remember you cna stop the watcher if you don't want to