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

Comparing libev/ev.pod (file contents):
Revision 1.99 by root, Sat Dec 22 06:16:36 2007 UTC vs.
Revision 1.100 by root, Sat Dec 22 11:49:17 2007 UTC

339(or space) is available. 339(or space) is available.
340 340
341=item C<EVBACKEND_KQUEUE> (value 8, most BSD clones) 341=item C<EVBACKEND_KQUEUE> (value 8, most BSD clones)
342 342
343Kqueue deserves special mention, as at the time of this writing, it 343Kqueue deserves special mention, as at the time of this writing, it
344was broken on I<all> BSDs (usually it doesn't work with anything but 344was broken on all BSDs except NetBSD (usually it doesn't work reliably
345sockets and pipes, except on Darwin, where of course it's completely 345with anything but sockets and pipes, except on Darwin, where of course
346useless. On NetBSD, it seems to work for all the FD types I tested, so it
347is used by default there). For this reason it's not being "autodetected" 346it's completely useless). For this reason it's not being "autodetected"
348unless you explicitly specify it explicitly in the flags (i.e. using 347unless you explicitly specify it explicitly in the flags (i.e. using
349C<EVBACKEND_KQUEUE>) or libev was compiled on a known-to-be-good (-enough) 348C<EVBACKEND_KQUEUE>) or libev was compiled on a known-to-be-good (-enough)
350system like NetBSD. 349system like NetBSD.
351 350
351You still can embed kqueue into a normal poll or select backend and use it
352only for sockets (after having made sure that sockets work with kqueue on
353the target platform). See C<ev_embed> watchers for more info.
354
352It scales in the same way as the epoll backend, but the interface to the 355It scales in the same way as the epoll backend, but the interface to the
353kernel is more efficient (which says nothing about its actual speed, 356kernel is more efficient (which says nothing about its actual speed, of
354of course). While stopping, setting and starting an I/O watcher does 357course). While stopping, setting and starting an I/O watcher does never
355never cause an extra syscall as with epoll, it still adds up to two event 358cause an extra syscall as with C<EVBACKEND_EPOLL>, it still adds up to
356changes per incident, support for C<fork ()> is very bad and it drops fds 359two event changes per incident, support for C<fork ()> is very bad and it
357silently in similarly hard-to-detetc cases. 360drops fds silently in similarly hard-to-detect cases.
358 361
359=item C<EVBACKEND_DEVPOLL> (value 16, Solaris 8) 362=item C<EVBACKEND_DEVPOLL> (value 16, Solaris 8)
360 363
361This is not implemented yet (and might never be). 364This is not implemented yet (and might never be).
362 365
1623 1626
1624It is recommended to give C<ev_check> watchers highest (C<EV_MAXPRI>) 1627It is recommended to give C<ev_check> watchers highest (C<EV_MAXPRI>)
1625priority, to ensure that they are being run before any other watchers 1628priority, to ensure that they are being run before any other watchers
1626after the poll. Also, C<ev_check> watchers (and C<ev_prepare> watchers, 1629after the poll. Also, C<ev_check> watchers (and C<ev_prepare> watchers,
1627too) should not activate ("feed") events into libev. While libev fully 1630too) should not activate ("feed") events into libev. While libev fully
1628supports this, they will be called before other C<ev_check> watchers did 1631supports this, they will be called before other C<ev_check> watchers
1629their job. As C<ev_check> watchers are often used to embed other event 1632did their job. As C<ev_check> watchers are often used to embed other
1630loops those other event loops might be in an unusable state until their 1633(non-libev) event loops those other event loops might be in an unusable
1631C<ev_check> watcher ran (always remind yourself to coexist peacefully with 1634state until their C<ev_check> watcher ran (always remind yourself to
1632others). 1635coexist peacefully with others).
1633 1636
1634=head3 Watcher-Specific Functions and Data Members 1637=head3 Watcher-Specific Functions and Data Members
1635 1638
1636=over 4 1639=over 4
1637 1640
1776=head2 C<ev_embed> - when one backend isn't enough... 1779=head2 C<ev_embed> - when one backend isn't enough...
1777 1780
1778This is a rather advanced watcher type that lets you embed one event loop 1781This is a rather advanced watcher type that lets you embed one event loop
1779into another (currently only C<ev_io> events are supported in the embedded 1782into another (currently only C<ev_io> events are supported in the embedded
1780loop, other types of watchers might be handled in a delayed or incorrect 1783loop, other types of watchers might be handled in a delayed or incorrect
1781fashion and must not be used). (See portability notes, below). 1784fashion and must not be used).
1782 1785
1783There are primarily two reasons you would want that: work around bugs and 1786There are primarily two reasons you would want that: work around bugs and
1784prioritise I/O. 1787prioritise I/O.
1785 1788
1786As an example for a bug workaround, the kqueue backend might only support 1789As an example for a bug workaround, the kqueue backend might only support
1841 ev_embed_start (loop_hi, &embed); 1844 ev_embed_start (loop_hi, &embed);
1842 } 1845 }
1843 else 1846 else
1844 loop_lo = loop_hi; 1847 loop_lo = loop_hi;
1845 1848
1846=head2 Portability notes
1847
1848Kqueue is nominally embeddable, but this is broken on all BSDs that I
1849tried, in various ways. Usually the embedded event loop will simply never
1850receive events, sometimes it will only trigger a few times, sometimes in a
1851loop. Epoll is also nominally embeddable, but many Linux kernel versions
1852will always eport the epoll fd as ready, even when no events are pending.
1853
1854While libev allows embedding these backends (they are contained in
1855C<ev_embeddable_backends ()>), take extreme care that it will actually
1856work.
1857
1858When in doubt, create a dynamic event loop forced to use sockets (this
1859usually works) and possibly another thread and a pipe or so to report to
1860your main event loop.
1861
1862=head3 Watcher-Specific Functions and Data Members 1849=head3 Watcher-Specific Functions and Data Members
1863 1850
1864=over 4 1851=over 4
1865 1852
1866=item ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop) 1853=item ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines