ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.3
(Generate patch)

Comparing libev/ev.3 (file contents):
Revision 1.38 by root, Fri Dec 7 18:09:38 2007 UTC vs.
Revision 1.39 by root, Fri Dec 7 19:15:39 2007 UTC

196\& return 0; 196\& return 0;
197\& } 197\& }
198.Ve 198.Ve
199.SH "DESCRIPTION" 199.SH "DESCRIPTION"
200.IX Header "DESCRIPTION" 200.IX Header "DESCRIPTION"
201The newest version of this document is also available as a html-formatted
202web page you might find easier to navigate when reading it for the first
203time: <http://cvs.schmorp.de/libev/ev.html>.
204.PP
201Libev is an event loop: you register interest in certain events (such as a 205Libev is an event loop: you register interest in certain events (such as a
202file descriptor being readable or a timeout occuring), and it will manage 206file descriptor being readable or a timeout occuring), and it will manage
203these event sources and provide your program with events. 207these event sources and provide your program with events.
204.PP 208.PP
205To do this, it must take more or less complete control over your process 209To do this, it must take more or less complete control over your process
2274If undefined or defined to \f(CW1\fR, then all event-loop-specific functions 2278If undefined or defined to \f(CW1\fR, then all event-loop-specific functions
2275will have the \f(CW\*(C`struct ev_loop *\*(C'\fR as first argument, and you can create 2279will have the \f(CW\*(C`struct ev_loop *\*(C'\fR as first argument, and you can create
2276additional independent event loops. Otherwise there will be no support 2280additional independent event loops. Otherwise there will be no support
2277for multiple event loops and there is no first event loop pointer 2281for multiple event loops and there is no first event loop pointer
2278argument. Instead, all functions act on the single default loop. 2282argument. Instead, all functions act on the single default loop.
2283.IP "\s-1EV_MINPRI\s0" 4
2284.IX Item "EV_MINPRI"
2285.PD 0
2286.IP "\s-1EV_MAXPRI\s0" 4
2287.IX Item "EV_MAXPRI"
2288.PD
2289The range of allowed priorities. \f(CW\*(C`EV_MINPRI\*(C'\fR must be smaller or equal to
2290\&\f(CW\*(C`EV_MAXPRI\*(C'\fR, but otherwise there are no non-obvious limitations. You can
2291provide for more priorities by overriding those symbols (usually defined
2292to be \f(CW\*(C`\-2\*(C'\fR and \f(CW2\fR, respectively).
2293.Sp
2294When doing priority-based operations, libev usually has to linearly search
2295all the priorities, so having many of them (hundreds) uses a lot of space
2296and time, so using the defaults of five priorities (\-2 .. +2) is usually
2297fine.
2298.Sp
2299If your embedding app does not need any priorities, defining these both to
2300\&\f(CW0\fR will save some memory and cpu.
2279.IP "\s-1EV_PERIODIC_ENABLE\s0" 4 2301.IP "\s-1EV_PERIODIC_ENABLE\s0" 4
2280.IX Item "EV_PERIODIC_ENABLE" 2302.IX Item "EV_PERIODIC_ENABLE"
2281If undefined or defined to be \f(CW1\fR, then periodic timers are supported. If 2303If undefined or defined to be \f(CW1\fR, then periodic timers are supported. If
2282defined to be \f(CW0\fR, then they are not. Disabling them saves a few kB of 2304defined to be \f(CW0\fR, then they are not. Disabling them saves a few kB of
2283code. 2305code.
2385libev will be explained. For complexity discussions about backends see the 2407libev will be explained. For complexity discussions about backends see the
2386documentation for \f(CW\*(C`ev_default_init\*(C'\fR. 2408documentation for \f(CW\*(C`ev_default_init\*(C'\fR.
2387.RS 4 2409.RS 4
2388.IP "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" 4 2410.IP "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" 4
2389.IX Item "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" 2411.IX Item "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)"
2390.PD 0 2412This means that, when you have a watcher that triggers in one hour and
2413there are 100 watchers that would trigger before that then inserting will
2414have to skip those 100 watchers.
2391.IP "Changing timer/periodic watchers (by autorepeat, again): O(log skipped_other_timers)" 4 2415.IP "Changing timer/periodic watchers (by autorepeat, again): O(log skipped_other_timers)" 4
2392.IX Item "Changing timer/periodic watchers (by autorepeat, again): O(log skipped_other_timers)" 2416.IX Item "Changing timer/periodic watchers (by autorepeat, again): O(log skipped_other_timers)"
2417That means that for changing a timer costs less than removing/adding them
2418as only the relative motion in the event queue has to be paid for.
2393.IP "Starting io/check/prepare/idle/signal/child watchers: O(1)" 4 2419.IP "Starting io/check/prepare/idle/signal/child watchers: O(1)" 4
2394.IX Item "Starting io/check/prepare/idle/signal/child watchers: O(1)" 2420.IX Item "Starting io/check/prepare/idle/signal/child watchers: O(1)"
2421These just add the watcher into an array or at the head of a list. If
2422the array needs to be extended libev needs to realloc and move the whole
2423array, but this happen asymptotically less and less with more watchers,
2424thus amortised O(1).
2395.IP "Stopping check/prepare/idle watchers: O(1)" 4 2425.IP "Stopping check/prepare/idle watchers: O(1)" 4
2396.IX Item "Stopping check/prepare/idle watchers: O(1)" 2426.IX Item "Stopping check/prepare/idle watchers: O(1)"
2427.PD 0
2397.IP "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % \s-1EV_PID_HASHSIZE\s0))" 4 2428.IP "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % \s-1EV_PID_HASHSIZE\s0))" 4
2398.IX Item "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE))" 2429.IX Item "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE))"
2430.PD
2431These watchers are stored in lists then need to be walked to find the
2432correct watcher to remove. The lists are usually short (you don't usually
2433have many watchers waiting for the same fd or signal).
2399.IP "Finding the next timer per loop iteration: O(1)" 4 2434.IP "Finding the next timer per loop iteration: O(1)" 4
2400.IX Item "Finding the next timer per loop iteration: O(1)" 2435.IX Item "Finding the next timer per loop iteration: O(1)"
2436.PD 0
2401.IP "Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)" 4 2437.IP "Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)" 4
2402.IX Item "Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)" 2438.IX Item "Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)"
2439.PD
2440A change means an I/O watcher gets started or stopped, which requires
2441libev to recalculate its status (and possibly tell the kernel).
2403.IP "Activating one watcher: O(1)" 4 2442.IP "Activating one watcher: O(1)" 4
2404.IX Item "Activating one watcher: O(1)" 2443.IX Item "Activating one watcher: O(1)"
2444.PD 0
2445.IP "Priority handling: O(number_of_priorities)" 4
2446.IX Item "Priority handling: O(number_of_priorities)"
2447.PD
2448Priorities are implemented by allocating some space for each
2449priority. When doing priority-based operations, libev usually has to
2450linearly search all the priorities.
2405.RE 2451.RE
2406.RS 4 2452.RS 4
2407.PD
2408.SH "AUTHOR" 2453.SH "AUTHOR"
2409.IX Header "AUTHOR" 2454.IX Header "AUTHOR"
2410Marc Lehmann <libev@schmorp.de>. 2455Marc Lehmann <libev@schmorp.de>.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines