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

Comparing libev/ev.3 (file contents):
Revision 1.23 by root, Tue Nov 27 08:20:42 2007 UTC vs.
Revision 1.24 by root, Tue Nov 27 10:59:10 2007 UTC

707\&\f(CW\*(C`ev_loop\*(C'\fR has gathered them, but before it invokes any callbacks for any 707\&\f(CW\*(C`ev_loop\*(C'\fR has gathered them, but before it invokes any callbacks for any
708received events. Callbacks of both watcher types can start and stop as 708received events. Callbacks of both watcher types can start and stop as
709many watchers as they want, and all of them will be taken into account 709many watchers as they want, and all of them will be taken into account
710(for example, a \f(CW\*(C`ev_prepare\*(C'\fR watcher might start an idle watcher to keep 710(for example, a \f(CW\*(C`ev_prepare\*(C'\fR watcher might start an idle watcher to keep
711\&\f(CW\*(C`ev_loop\*(C'\fR from blocking). 711\&\f(CW\*(C`ev_loop\*(C'\fR from blocking).
712.ie n .IP """EV_EMBED""" 4
713.el .IP "\f(CWEV_EMBED\fR" 4
714.IX Item "EV_EMBED"
715The embedded event loop specified in the \f(CW\*(C`ev_embed\*(C'\fR watcher needs attention.
716.ie n .IP """EV_FORK""" 4
717.el .IP "\f(CWEV_FORK\fR" 4
718.IX Item "EV_FORK"
719The event loop has been resumed in the child process after fork (see
720\&\f(CW\*(C`ev_fork\*(C'\fR).
712.ie n .IP """EV_ERROR""" 4 721.ie n .IP """EV_ERROR""" 4
713.el .IP "\f(CWEV_ERROR\fR" 4 722.el .IP "\f(CWEV_ERROR\fR" 4
714.IX Item "EV_ERROR" 723.IX Item "EV_ERROR"
715An unspecified error has occured, the watcher has been stopped. This might 724An unspecified error has occured, the watcher has been stopped. This might
716happen because the watcher could not be properly started because libev 725happen because the watcher could not be properly started because libev
1613similarly to \f(CW\*(C`ev_loop (embedded_loop, EVLOOP_NONBLOCK)\*(C'\fR, but in the most 1622similarly to \f(CW\*(C`ev_loop (embedded_loop, EVLOOP_NONBLOCK)\*(C'\fR, but in the most
1614apropriate way for embedded loops. 1623apropriate way for embedded loops.
1615.IP "struct ev_loop *loop [read\-only]" 4 1624.IP "struct ev_loop *loop [read\-only]" 4
1616.IX Item "struct ev_loop *loop [read-only]" 1625.IX Item "struct ev_loop *loop [read-only]"
1617The embedded event loop. 1626The embedded event loop.
1627.ie n .Sh """ev_fork"" \- the audacity to resume the event loop after a fork"
1628.el .Sh "\f(CWev_fork\fP \- the audacity to resume the event loop after a fork"
1629.IX Subsection "ev_fork - the audacity to resume the event loop after a fork"
1630Fork watchers are called when a \f(CW\*(C`fork ()\*(C'\fR was detected (usually because
1631whoever is a good citizen cared to tell libev about it by calling
1632\&\f(CW\*(C`ev_default_fork\*(C'\fR or \f(CW\*(C`ev_loop_fork\*(C'\fR). The invocation is done before the
1633event loop blocks next and before \f(CW\*(C`ev_check\*(C'\fR watchers are being called,
1634and only in the child after the fork. If whoever good citizen calling
1635\&\f(CW\*(C`ev_default_fork\*(C'\fR cheats and calls it in the wrong process, the fork
1636handlers will be invoked, too, of course.
1637.IP "ev_fork_init (ev_signal *, callback)" 4
1638.IX Item "ev_fork_init (ev_signal *, callback)"
1639Initialises and configures the fork watcher \- it has no parameters of any
1640kind. There is a \f(CW\*(C`ev_fork_set\*(C'\fR macro, but using it is utterly pointless,
1641believe me.
1618.SH "OTHER FUNCTIONS" 1642.SH "OTHER FUNCTIONS"
1619.IX Header "OTHER FUNCTIONS" 1643.IX Header "OTHER FUNCTIONS"
1620There are some other functions of possible interest. Described. Here. Now. 1644There are some other functions of possible interest. Described. Here. Now.
1621.IP "ev_once (loop, int fd, int events, ev_tstamp timeout, callback)" 4 1645.IP "ev_once (loop, int fd, int events, ev_tstamp timeout, callback)" 4
1622.IX Item "ev_once (loop, int fd, int events, ev_tstamp timeout, callback)" 1646.IX Item "ev_once (loop, int fd, int events, ev_tstamp timeout, callback)"
1791\& : io (this, &myclass::io_cb), 1815\& : io (this, &myclass::io_cb),
1792\& idle (this, &myclass::idle_cb) 1816\& idle (this, &myclass::idle_cb)
1793\& { 1817\& {
1794\& io.start (fd, ev::READ); 1818\& io.start (fd, ev::READ);
1795\& } 1819\& }
1820.Ve
1821.SH "MACRO MAGIC"
1822.IX Header "MACRO MAGIC"
1823Libev can be compiled with a variety of options, the most fundemantal is
1824\&\f(CW\*(C`EV_MULTIPLICITY\*(C'\fR. This option determines wether (most) functions and
1825callbacks have an initial \f(CW\*(C`struct ev_loop *\*(C'\fR argument.
1826.PP
1827To make it easier to write programs that cope with either variant, the
1828following macros are defined:
1829.ie n .IP """EV_A""\fR, \f(CW""EV_A_""" 4
1830.el .IP "\f(CWEV_A\fR, \f(CWEV_A_\fR" 4
1831.IX Item "EV_A, EV_A_"
1832This provides the loop \fIargument\fR for functions, if one is required (\*(L"ev
1833loop argument\*(R"). The \f(CW\*(C`EV_A\*(C'\fR form is used when this is the sole argument,
1834\&\f(CW\*(C`EV_A_\*(C'\fR is used when other arguments are following. Example:
1835.Sp
1836.Vb 3
1837\& ev_unref (EV_A);
1838\& ev_timer_add (EV_A_ watcher);
1839\& ev_loop (EV_A_ 0);
1840.Ve
1841.Sp
1842It assumes the variable \f(CW\*(C`loop\*(C'\fR of type \f(CW\*(C`struct ev_loop *\*(C'\fR is in scope,
1843which is often provided by the following macro.
1844.ie n .IP """EV_P""\fR, \f(CW""EV_P_""" 4
1845.el .IP "\f(CWEV_P\fR, \f(CWEV_P_\fR" 4
1846.IX Item "EV_P, EV_P_"
1847This provides the loop \fIparameter\fR for functions, if one is required (\*(L"ev
1848loop parameter\*(R"). The \f(CW\*(C`EV_P\*(C'\fR form is used when this is the sole parameter,
1849\&\f(CW\*(C`EV_P_\*(C'\fR is used when other parameters are following. Example:
1850.Sp
1851.Vb 2
1852\& // this is how ev_unref is being declared
1853\& static void ev_unref (EV_P);
1854.Ve
1855.Sp
1856.Vb 2
1857\& // this is how you can declare your typical callback
1858\& static void cb (EV_P_ ev_timer *w, int revents)
1859.Ve
1860.Sp
1861It declares a parameter \f(CW\*(C`loop\*(C'\fR of type \f(CW\*(C`struct ev_loop *\*(C'\fR, quite
1862suitable for use with \f(CW\*(C`EV_A\*(C'\fR.
1863.ie n .IP """EV_DEFAULT""\fR, \f(CW""EV_DEFAULT_""" 4
1864.el .IP "\f(CWEV_DEFAULT\fR, \f(CWEV_DEFAULT_\fR" 4
1865.IX Item "EV_DEFAULT, EV_DEFAULT_"
1866Similar to the other two macros, this gives you the value of the default
1867loop, if multiple loops are supported (\*(L"ev loop default\*(R").
1868.PP
1869Example: Declare and initialise a check watcher, working regardless of
1870wether multiple loops are supported or not.
1871.PP
1872.Vb 5
1873\& static void
1874\& check_cb (EV_P_ ev_timer *w, int revents)
1875\& {
1876\& ev_check_stop (EV_A_ w);
1877\& }
1878.Ve
1879.PP
1880.Vb 4
1881\& ev_check check;
1882\& ev_check_init (&check, check_cb);
1883\& ev_check_start (EV_DEFAULT_ &check);
1884\& ev_loop (EV_DEFAULT_ 0);
1796.Ve 1885.Ve
1797.SH "EMBEDDING" 1886.SH "EMBEDDING"
1798.IX Header "EMBEDDING" 1887.IX Header "EMBEDDING"
1799Libev can (and often is) directly embedded into host 1888Libev can (and often is) directly embedded into host
1800applications. Examples of applications that embed it include the Deliantra 1889applications. Examples of applications that embed it include the Deliantra
2020defined to be \f(CW0\fR, then they are not. 2109defined to be \f(CW0\fR, then they are not.
2021.IP "\s-1EV_STAT_ENABLE\s0" 4 2110.IP "\s-1EV_STAT_ENABLE\s0" 4
2022.IX Item "EV_STAT_ENABLE" 2111.IX Item "EV_STAT_ENABLE"
2023If undefined or defined to be \f(CW1\fR, then stat watchers are supported. If 2112If undefined or defined to be \f(CW1\fR, then stat watchers are supported. If
2024defined to be \f(CW0\fR, then they are not. 2113defined to be \f(CW0\fR, then they are not.
2114.IP "\s-1EV_FORK_ENABLE\s0" 4
2115.IX Item "EV_FORK_ENABLE"
2116If undefined or defined to be \f(CW1\fR, then fork watchers are supported. If
2117defined to be \f(CW0\fR, then they are not.
2025.IP "\s-1EV_MINIMAL\s0" 4 2118.IP "\s-1EV_MINIMAL\s0" 4
2026.IX Item "EV_MINIMAL" 2119.IX Item "EV_MINIMAL"
2027If you need to shave off some kilobytes of code at the expense of some 2120If you need to shave off some kilobytes of code at the expense of some
2028speed, define this symbol to \f(CW1\fR. Currently only used for gcc to override 2121speed, define this symbol to \f(CW1\fR. Currently only used for gcc to override
2029some inlining decisions, saves roughly 30% codesize of amd64. 2122some inlining decisions, saves roughly 30% codesize of amd64.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines