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

Comparing libev/ev.html (file contents):
Revision 1.1 by root, Mon Nov 12 07:58:13 2007 UTC vs.
Revision 1.6 by root, Mon Nov 12 08:12:14 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="Mon Nov 12 08:58:02 2007" /> 9 <meta name="created" content="Mon Nov 12 09:12:14 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 -->
26</ul> 26</ul>
27</li> 27</li>
28<li><a href="#WATCHER_TYPES">WATCHER TYPES</a> 28<li><a href="#WATCHER_TYPES">WATCHER TYPES</a>
29<ul><li><a href="#struct_ev_io_is_my_file_descriptor_r">struct ev_io - is my file descriptor readable or writable</a></li> 29<ul><li><a href="#struct_ev_io_is_my_file_descriptor_r">struct ev_io - is my file descriptor readable or writable</a></li>
30<li><a href="#struct_ev_timer_relative_and_optiona">struct ev_timer - relative and optionally recurring timeouts</a></li> 30<li><a href="#struct_ev_timer_relative_and_optiona">struct ev_timer - relative and optionally recurring timeouts</a></li>
31<li><a href="#ev_periodic">ev_periodic</a></li> 31<li><a href="#ev_periodic_to_cron_or_not_to_cron_i">ev_periodic - to cron or not to cron it</a></li>
32<li><a href="#ev_signal_signal_me_when_a_signal_ge">ev_signal - signal me when a signal gets signalled</a></li> 32<li><a href="#ev_signal_signal_me_when_a_signal_ge">ev_signal - signal me when a signal gets signalled</a></li>
33<li><a href="#ev_child_wait_for_pid_status_changes">ev_child - wait for pid status changes</a></li> 33<li><a href="#ev_child_wait_for_pid_status_changes">ev_child - wait for pid status changes</a></li>
34<li><a href="#ev_idle_when_you_ve_got_nothing_bett">ev_idle - when you've got nothing better to do</a></li> 34<li><a href="#ev_idle_when_you_ve_got_nothing_bett">ev_idle - when you've got nothing better to do</a></li>
35<li><a href="#prepare_and_check_your_hooks_into_th">prepare and check - your hooks into the event loop</a></li> 35<li><a href="#prepare_and_check_your_hooks_into_th">prepare and check - your hooks into the event loop</a></li>
36</ul> 36</ul>
55</div> 55</div>
56<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p> 56<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
57<div id="DESCRIPTION_CONTENT"> 57<div id="DESCRIPTION_CONTENT">
58<p>Libev is an event loop: you register interest in certain events (such as a 58<p>Libev is an event loop: you register interest in certain events (such as a
59file descriptor being readable or a timeout occuring), and it will manage 59file descriptor being readable or a timeout occuring), and it will manage
60these event sources and provide your program events.</p> 60these event sources and provide your program with events.</p>
61<p>To do this, it must take more or less complete control over your process 61<p>To do this, it must take more or less complete control over your process
62(or thread) by executing the <i>event loop</i> handler, and will then 62(or thread) by executing the <i>event loop</i> handler, and will then
63communicate events via a callback mechanism.</p> 63communicate events via a callback mechanism.</p>
64<p>You register interest in certain events by registering so-called <i>event 64<p>You register interest in certain events by registering so-called <i>event
65watchers</i>, which are relatively small C structures you initialise with the 65watchers</i>, which are relatively small C structures you initialise with the
71<div id="FEATURES_CONTENT"> 71<div id="FEATURES_CONTENT">
72<p>Libev supports select, poll, the linux-specific epoll and the bsd-specific 72<p>Libev supports select, poll, the linux-specific epoll and the bsd-specific
73kqueue mechanisms for file descriptor events, relative timers, absolute 73kqueue mechanisms for file descriptor events, relative timers, absolute
74timers with customised rescheduling, signal events, process status change 74timers with customised rescheduling, signal events, process status change
75events (related to SIGCHLD), and event watchers dealing with the event 75events (related to SIGCHLD), and event watchers dealing with the event
76loop mechanism itself (idle, prepare and check watchers).</p> 76loop mechanism itself (idle, prepare and check watchers). It also is quite
77fast (see a <a href="http://libev.schmorp.de/bench.html">benchmark</a> comparing it
78to libevent).</p>
77 79
78</div> 80</div>
79<h1 id="CONVENTIONS">CONVENTIONS</h1><p><a href="#TOP" class="toplink">Top</a></p> 81<h1 id="CONVENTIONS">CONVENTIONS</h1><p><a href="#TOP" class="toplink">Top</a></p>
80<div id="CONVENTIONS_CONTENT"> 82<div id="CONVENTIONS_CONTENT">
81<p>Libev is very configurable. In this manual the default configuration 83<p>Libev is very configurable. In this manual the default configuration
87will not have this argument.</p> 89will not have this argument.</p>
88 90
89</div> 91</div>
90<h1 id="TIME_AND_OTHER_GLOBAL_FUNCTIONS">TIME AND OTHER GLOBAL FUNCTIONS</h1><p><a href="#TOP" class="toplink">Top</a></p> 92<h1 id="TIME_AND_OTHER_GLOBAL_FUNCTIONS">TIME AND OTHER GLOBAL FUNCTIONS</h1><p><a href="#TOP" class="toplink">Top</a></p>
91<div id="TIME_AND_OTHER_GLOBAL_FUNCTIONS_CONT"> 93<div id="TIME_AND_OTHER_GLOBAL_FUNCTIONS_CONT">
92<p>Libev represents time as a single floating point number. This type is 94<p>Libev represents time as a single floating point number, representing the
95(fractional) number of seconds since the (POSIX) epoch (somewhere near
96the beginning of 1970, details are complicated, don't ask). This type is
93called <code>ev_tstamp</code>, which is what you should use too. It usually aliases 97called <code>ev_tstamp</code>, which is what you should use too. It usually aliases
94to the double type in C.</p> 98to the double type in C.</p>
95<dl> 99<dl>
96 <dt>ev_tstamp ev_time ()</dt> 100 <dt>ev_tstamp ev_time ()</dt>
97 <dd> 101 <dd>
314*)</code>), and you can stop watching for events at any time by calling the 318*)</code>), and you can stop watching for events at any time by calling the
315corresponding stop function (<code>ev_&lt;type&gt;_stop (loop, watcher *)</code>.</p> 319corresponding stop function (<code>ev_&lt;type&gt;_stop (loop, watcher *)</code>.</p>
316<p>As long as your watcher is active (has been started but not stopped) you 320<p>As long as your watcher is active (has been started but not stopped) you
317must not touch the values stored in it. Most specifically you must never 321must not touch the values stored in it. Most specifically you must never
318reinitialise it or call its set method.</p> 322reinitialise it or call its set method.</p>
319<p>You cna check wether an event is active by calling the <code>ev_is_active 323<p>You cna check whether an event is active by calling the <code>ev_is_active
320(watcher *)</code> macro. To see wether an event is outstanding (but the 324(watcher *)</code> macro. To see whether an event is outstanding (but the
321callback for it has not been called yet) you cna use the <code>ev_is_pending 325callback for it has not been called yet) you cna use the <code>ev_is_pending
322(watcher *)</code> macro.</p> 326(watcher *)</code> macro.</p>
323<p>Each and every callback receives the event loop pointer as first, the 327<p>Each and every callback receives the event loop pointer as first, the
324registered watcher structure as second, and a bitset of received events as 328registered watcher structure as second, and a bitset of received events as
325third argument.</p> 329third argument.</p>
420information given in the last section.</p> 424information given in the last section.</p>
421 425
422</div> 426</div>
423<h2 id="struct_ev_io_is_my_file_descriptor_r">struct ev_io - is my file descriptor readable or writable</h2> 427<h2 id="struct_ev_io_is_my_file_descriptor_r">struct ev_io - is my file descriptor readable or writable</h2>
424<div id="struct_ev_io_is_my_file_descriptor_r-2"> 428<div id="struct_ev_io_is_my_file_descriptor_r-2">
425<p>I/O watchers check wether a file descriptor is readable or writable 429<p>I/O watchers check whether a file descriptor is readable or writable
426in each iteration of the event loop (This behaviour is called 430in each iteration of the event loop (This behaviour is called
427level-triggering because you keep receiving events as long as the 431level-triggering because you keep receiving events as long as the
428condition persists. Remember you cna stop the watcher if you don't want to 432condition persists. Remember you cna stop the watcher if you don't want to
429act on the event and neither want to receive future events).</p> 433act on the event and neither want to receive future events).</p>
430<dl> 434<dl>
478the timer, and again will automatically restart it if need be.</p> 482the timer, and again will automatically restart it if need be.</p>
479 </dd> 483 </dd>
480</dl> 484</dl>
481 485
482</div> 486</div>
483<h2 id="ev_periodic">ev_periodic</h2> 487<h2 id="ev_periodic_to_cron_or_not_to_cron_i">ev_periodic - to cron or not to cron it</h2>
484<div id="ev_periodic_CONTENT"> 488<div id="ev_periodic_to_cron_or_not_to_cron_i-2">
485<p>Periodic watchers are also timers of a kind, but they are very versatile 489<p>Periodic watchers are also timers of a kind, but they are very versatile
486(and unfortunately a bit complex).</p> 490(and unfortunately a bit complex).</p>
487<p>Unlike ev_timer's, they are not based on real time (or relative time) 491<p>Unlike ev_timer's, they are not based on real time (or relative time)
488but on wallclock time (absolute time). You can tell a periodic watcher 492but on wallclock time (absolute time). You can tell a periodic watcher
489to trigger &quot;at&quot; some specific point in time. For example, if you tell a 493to trigger &quot;at&quot; some specific point in time. For example, if you tell a

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines