… | |
… | |
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="<standard input>" /> |
7 | <meta name="inputfile" content="<standard input>" /> |
8 | <meta name="outputfile" content="<standard output>" /> |
8 | <meta name="outputfile" content="<standard output>" /> |
9 | <meta name="created" content="Fri Nov 23 06:14:47 2007" /> |
9 | <meta name="created" content="Fri Nov 23 09:26:40 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 --> |
… | |
… | |
228 | <p>While stopping and starting an I/O watcher in the same iteration will |
228 | <p>While stopping and starting an I/O watcher in the same iteration will |
229 | result in some caching, there is still a syscall per such incident |
229 | result in some caching, there is still a syscall per such incident |
230 | (because the fd could point to a different file description now), so its |
230 | (because the fd could point to a different file description now), so its |
231 | best to avoid that. Also, dup()ed file descriptors might not work very |
231 | best to avoid that. Also, dup()ed file descriptors might not work very |
232 | well if you register events for both fds.</p> |
232 | well if you register events for both fds.</p> |
|
|
233 | <p>Please note that epoll sometimes generates spurious notifications, so you |
|
|
234 | need to use non-blocking I/O or other means to avoid blocking when no data |
|
|
235 | (or space) is available.</p> |
233 | </dd> |
236 | </dd> |
234 | <dt><code>EVBACKEND_KQUEUE</code> (value 8, most BSD clones)</dt> |
237 | <dt><code>EVBACKEND_KQUEUE</code> (value 8, most BSD clones)</dt> |
235 | <dd> |
238 | <dd> |
236 | <p>Kqueue deserves special mention, as at the time of this writing, it |
239 | <p>Kqueue deserves special mention, as at the time of this writing, it |
237 | was broken on all BSDs except NetBSD (usually it doesn't work with |
240 | was broken on all BSDs except NetBSD (usually it doesn't work with |
… | |
… | |
250 | </dd> |
253 | </dd> |
251 | <dt><code>EVBACKEND_PORT</code> (value 32, Solaris 10)</dt> |
254 | <dt><code>EVBACKEND_PORT</code> (value 32, Solaris 10)</dt> |
252 | <dd> |
255 | <dd> |
253 | <p>This uses the Solaris 10 port mechanism. As with everything on Solaris, |
256 | <p>This uses the Solaris 10 port mechanism. As with everything on Solaris, |
254 | it's really slow, but it still scales very well (O(active_fds)).</p> |
257 | it's really slow, but it still scales very well (O(active_fds)).</p> |
|
|
258 | <p>Please note that solaris ports can result in a lot of spurious |
|
|
259 | notifications, so you need to use non-blocking I/O or other means to avoid |
|
|
260 | blocking when no data (or space) is available.</p> |
255 | </dd> |
261 | </dd> |
256 | <dt><code>EVBACKEND_ALL</code></dt> |
262 | <dt><code>EVBACKEND_ALL</code></dt> |
257 | <dd> |
263 | <dd> |
258 | <p>Try all backends (even potentially broken ones that wouldn't be tried |
264 | <p>Try all backends (even potentially broken ones that wouldn't be tried |
259 | with <code>EVFLAG_AUTO</code>). Since this is a mask, you can do stuff such as |
265 | with <code>EVFLAG_AUTO</code>). Since this is a mask, you can do stuff such as |
… | |
… | |
548 | <dt>ev_io_set (ev_io *, int fd, int events)</dt> |
554 | <dt>ev_io_set (ev_io *, int fd, int events)</dt> |
549 | <dd> |
555 | <dd> |
550 | <p>Configures an <code>ev_io</code> watcher. The fd is the file descriptor to rceeive |
556 | <p>Configures an <code>ev_io</code> watcher. The fd is the file descriptor to rceeive |
551 | events for and events is either <code>EV_READ</code>, <code>EV_WRITE</code> or <code>EV_READ | |
557 | events for and events is either <code>EV_READ</code>, <code>EV_WRITE</code> or <code>EV_READ | |
552 | EV_WRITE</code> to receive the given events.</p> |
558 | EV_WRITE</code> to receive the given events.</p> |
|
|
559 | <p>Please note that most of the more scalable backend mechanisms (for example |
|
|
560 | epoll and solaris ports) can result in spurious readyness notifications |
|
|
561 | for file descriptors, so you practically need to use non-blocking I/O (and |
|
|
562 | treat callback invocation as hint only), or retest separately with a safe |
|
|
563 | interface before doing I/O (XLib can do this), or force the use of either |
|
|
564 | <code>EVBACKEND_SELECT</code> or <code>EVBACKEND_POLL</code>, which don't suffer from this |
|
|
565 | problem. Also note that it is quite easy to have your callback invoked |
|
|
566 | when the readyness condition is no longer valid even when employing |
|
|
567 | typical ways of handling events, so its a good idea to use non-blocking |
|
|
568 | I/O unconditionally.</p> |
553 | </dd> |
569 | </dd> |
554 | </dl> |
570 | </dl> |
555 | |
571 | |
556 | </div> |
572 | </div> |
557 | <h2 id="code_ev_timer_code_relative_and_opti"><code>ev_timer</code> - relative and optionally recurring timeouts</h2> |
573 | <h2 id="code_ev_timer_code_relative_and_opti"><code>ev_timer</code> - relative and optionally recurring timeouts</h2> |