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

Comparing libev/ev.html (file contents):
Revision 1.65 by root, Fri Dec 7 18:09:40 2007 UTC vs.
Revision 1.66 by root, Fri Dec 7 19:15:39 2007 UTC

4<head> 4<head>
5 <title>libev</title> 5 <title>libev</title>
6 <meta name="description" content="Pod documentation for libev" /> 6 <meta name="description" content="Pod documentation for libev" />
7 <meta name="inputfile" content="&lt;standard input&gt;" /> 7 <meta name="inputfile" content="&lt;standard input&gt;" />
8 <meta name="outputfile" content="&lt;standard output&gt;" /> 8 <meta name="outputfile" content="&lt;standard output&gt;" />
9 <meta name="created" content="Fri Dec 7 19:03:06 2007" /> 9 <meta name="created" content="Fri Dec 7 20:07:44 2007" />
10 <meta name="generator" content="Pod::Xhtml 1.57" /> 10 <meta name="generator" content="Pod::Xhtml 1.57" />
11<link rel="stylesheet" href="http://res.tst.eu/pod.css"/></head> 11<link rel="stylesheet" href="http://res.tst.eu/pod.css"/></head>
12<body> 12<body>
13<div class="pod"> 13<div class="pod">
14<!-- INDEX START --> 14<!-- INDEX START -->
119</pre> 119</pre>
120 120
121</div> 121</div>
122<h1 id="DESCRIPTION">DESCRIPTION</h1> 122<h1 id="DESCRIPTION">DESCRIPTION</h1>
123<div id="DESCRIPTION_CONTENT"> 123<div id="DESCRIPTION_CONTENT">
124<p>The newest version of this document is also available as a html-formatted
125web page you might find easier to navigate when reading it for the first
126time: <a href="http://cvs.schmorp.de/libev/ev.html">http://cvs.schmorp.de/libev/ev.html</a>.</p>
124<p>Libev is an event loop: you register interest in certain events (such as a 127<p>Libev is an event loop: you register interest in certain events (such as a
125file descriptor being readable or a timeout occuring), and it will manage 128file descriptor being readable or a timeout occuring), and it will manage
126these event sources and provide your program with events.</p> 129these event sources and provide your program with events.</p>
127<p>To do this, it must take more or less complete control over your process 130<p>To do this, it must take more or less complete control over your process
128(or thread) by executing the <i>event loop</i> handler, and will then 131(or thread) by executing the <i>event loop</i> handler, and will then
2110will have the <code>struct ev_loop *</code> as first argument, and you can create 2113will have the <code>struct ev_loop *</code> as first argument, and you can create
2111additional independent event loops. Otherwise there will be no support 2114additional independent event loops. Otherwise there will be no support
2112for multiple event loops and there is no first event loop pointer 2115for multiple event loops and there is no first event loop pointer
2113argument. Instead, all functions act on the single default loop.</p> 2116argument. Instead, all functions act on the single default loop.</p>
2114 </dd> 2117 </dd>
2118 <dt>EV_MINPRI</dt>
2119 <dt>EV_MAXPRI</dt>
2120 <dd>
2121 <p>The range of allowed priorities. <code>EV_MINPRI</code> must be smaller or equal to
2122<code>EV_MAXPRI</code>, but otherwise there are no non-obvious limitations. You can
2123provide for more priorities by overriding those symbols (usually defined
2124to be <code>-2</code> and <code>2</code>, respectively).</p>
2125 <p>When doing priority-based operations, libev usually has to linearly search
2126all the priorities, so having many of them (hundreds) uses a lot of space
2127and time, so using the defaults of five priorities (-2 .. +2) is usually
2128fine.</p>
2129 <p>If your embedding app does not need any priorities, defining these both to
2130<code>0</code> will save some memory and cpu.</p>
2131 </dd>
2115 <dt>EV_PERIODIC_ENABLE</dt> 2132 <dt>EV_PERIODIC_ENABLE</dt>
2116 <dd> 2133 <dd>
2117 <p>If undefined or defined to be <code>1</code>, then periodic timers are supported. If 2134 <p>If undefined or defined to be <code>1</code>, then periodic timers are supported. If
2118defined to be <code>0</code>, then they are not. Disabling them saves a few kB of 2135defined to be <code>0</code>, then they are not. Disabling them saves a few kB of
2119code.</p> 2136code.</p>
2225libev will be explained. For complexity discussions about backends see the 2242libev will be explained. For complexity discussions about backends see the
2226documentation for <code>ev_default_init</code>.</p> 2243documentation for <code>ev_default_init</code>.</p>
2227 <p> 2244 <p>
2228 <dl> 2245 <dl>
2229 <dt>Starting and stopping timer/periodic watchers: O(log skipped_other_timers)</dt> 2246 <dt>Starting and stopping timer/periodic watchers: O(log skipped_other_timers)</dt>
2247 <dd>
2248 <p>This means that, when you have a watcher that triggers in one hour and
2249there are 100 watchers that would trigger before that then inserting will
2250have to skip those 100 watchers.</p>
2251 </dd>
2230 <dt>Changing timer/periodic watchers (by autorepeat, again): O(log skipped_other_timers)</dt> 2252 <dt>Changing timer/periodic watchers (by autorepeat, again): O(log skipped_other_timers)</dt>
2253 <dd>
2254 <p>That means that for changing a timer costs less than removing/adding them
2255as only the relative motion in the event queue has to be paid for.</p>
2256 </dd>
2231 <dt>Starting io/check/prepare/idle/signal/child watchers: O(1)</dt> 2257 <dt>Starting io/check/prepare/idle/signal/child watchers: O(1)</dt>
2258 <dd>
2259 <p>These just add the watcher into an array or at the head of a list. If
2260the array needs to be extended libev needs to realloc and move the whole
2261array, but this happen asymptotically less and less with more watchers,
2262thus amortised O(1).</p>
2263 </dd>
2232 <dt>Stopping check/prepare/idle watchers: O(1)</dt> 2264 <dt>Stopping check/prepare/idle watchers: O(1)</dt>
2233 <dt>Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE))</dt> 2265 <dt>Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE))</dt>
2266 <dd>
2267 <p>These watchers are stored in lists then need to be walked to find the
2268correct watcher to remove. The lists are usually short (you don't usually
2269have many watchers waiting for the same fd or signal).</p>
2270 </dd>
2234 <dt>Finding the next timer per loop iteration: O(1)</dt> 2271 <dt>Finding the next timer per loop iteration: O(1)</dt>
2235 <dt>Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)</dt> 2272 <dt>Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)</dt>
2273 <dd>
2274 <p>A change means an I/O watcher gets started or stopped, which requires
2275libev to recalculate its status (and possibly tell the kernel).</p>
2276 </dd>
2236 <dt>Activating one watcher: O(1)</dt> 2277 <dt>Activating one watcher: O(1)</dt>
2278 <dt>Priority handling: O(number_of_priorities)</dt>
2279 <dd>
2280 <p>Priorities are implemented by allocating some space for each
2281priority. When doing priority-based operations, libev usually has to
2282linearly search all the priorities.</p>
2283 </dd>
2237 </dl> 2284 </dl>
2238 </p> 2285 </p>
2239 2286
2240 2287
2241 2288

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines