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

Comparing libev/ev.html (file contents):
Revision 1.6 by root, Mon Nov 12 08:12:14 2007 UTC vs.
Revision 1.7 by root, Mon Nov 12 08:16:02 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 09:12:14 2007" /> 9 <meta name="created" content="Mon Nov 12 09:16:01 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 -->
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). It also is quite 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 77fast (see this <a href="http://libev.schmorp.de/bench.html">benchmark</a> comparing
78to libevent).</p> 78it to libevent for example).</p>
79 79
80</div> 80</div>
81<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>
82<div id="CONVENTIONS_CONTENT"> 82<div id="CONVENTIONS_CONTENT">
83<p>Libev is very configurable. In this manual the default configuration 83<p>Libev is very configurable. In this manual the default configuration
84will be described, which supports multiple event loops. For more info 84will be described, which supports multiple event loops. For more info
85about various configuraiton options please have a look at the file 85about various configuration options please have a look at the file
86<cite>README.embed</cite> in the libev distribution. If libev was configured without 86<cite>README.embed</cite> in the libev distribution. If libev was configured without
87support for multiple event loops, then all functions taking an initial 87support for multiple event loops, then all functions taking an initial
88argument of name <code>loop</code> (which is always of type <code>struct ev_loop *</code>) 88argument of name <code>loop</code> (which is always of type <code>struct ev_loop *</code>)
89will not have this argument.</p> 89will not have this argument.</p>
90 90
115not a problem.</p> 115not a problem.</p>
116 </dd> 116 </dd>
117 <dt>ev_set_allocator (void *(*cb)(void *ptr, long size))</dt> 117 <dt>ev_set_allocator (void *(*cb)(void *ptr, long size))</dt>
118 <dd> 118 <dd>
119 <p>Sets the allocation function to use (the prototype is similar to the 119 <p>Sets the allocation function to use (the prototype is similar to the
120realloc function). It is used to allocate and free memory (no surprises 120realloc C function, the semantics are identical). It is used to allocate
121here). If it returns zero when memory needs to be allocated, the library 121and free memory (no surprises here). If it returns zero when memory
122might abort or take some potentially destructive action. The default is 122needs to be allocated, the library might abort or take some potentially
123your system realloc function.</p> 123destructive action. The default is your system realloc function.</p>
124 <p>You could override this function in high-availability programs to, say, 124 <p>You could override this function in high-availability programs to, say,
125free some memory if it cannot allocate memory, to use a special allocator, 125free some memory if it cannot allocate memory, to use a special allocator,
126or even to sleep a while and retry until some memory is available.</p> 126or even to sleep a while and retry until some memory is available.</p>
127 </dd> 127 </dd>
128 <dt>ev_set_syserr_cb (void (*cb)(const char *msg));</dt> 128 <dt>ev_set_syserr_cb (void (*cb)(const char *msg));</dt>
129 <dd> 129 <dd>
130 <p>Set the callback function to call on a retryable syscall error (such 130 <p>Set the callback function to call on a retryable syscall error (such
131as failed select, poll, epoll_wait). The message is a printable string 131as failed select, poll, epoll_wait). The message is a printable string
132indicating the system call or subsystem causing the problem. If this 132indicating the system call or subsystem causing the problem. If this
133callback is set, then libev will expect it to remedy the sitution, no 133callback is set, then libev will expect it to remedy the sitution, no
134matter what, when it returns. That is, libev will geenrally retry the 134matter what, when it returns. That is, libev will generally retry the
135requested operation, or, if the condition doesn't go away, do bad stuff 135requested operation, or, if the condition doesn't go away, do bad stuff
136(such as abort).</p> 136(such as abort).</p>
137 </dd> 137 </dd>
138</dl> 138</dl>
139 139
143<p>An event loop is described by a <code>struct ev_loop *</code>. The library knows two 143<p>An event loop is described by a <code>struct ev_loop *</code>. The library knows two
144types of such loops, the <i>default</i> loop, which supports signals and child 144types of such loops, the <i>default</i> loop, which supports signals and child
145events, and dynamically created loops which do not.</p> 145events, and dynamically created loops which do not.</p>
146<p>If you use threads, a common model is to run the default event loop 146<p>If you use threads, a common model is to run the default event loop
147in your main thread (or in a separate thrad) and for each thread you 147in your main thread (or in a separate thrad) and for each thread you
148create, you also create another event loop. Libev itself does no lockign 148create, you also create another event loop. Libev itself does no locking
149whatsoever, so if you mix calls to different event loops, make sure you 149whatsoever, so if you mix calls to the same event loop in different
150lock (this is usually a bad idea, though, even if done right).</p> 150threads, make sure you lock (this is usually a bad idea, though, even if
151done correctly, because its hideous and inefficient).</p>
151<dl> 152<dl>
152 <dt>struct ev_loop *ev_default_loop (unsigned int flags)</dt> 153 <dt>struct ev_loop *ev_default_loop (unsigned int flags)</dt>
153 <dd> 154 <dd>
154 <p>This will initialise the default event loop if it hasn't been initialised 155 <p>This will initialise the default event loop if it hasn't been initialised
155yet and return it. If the default loop could not be initialised, returns 156yet and return it. If the default loop could not be initialised, returns

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines