… | |
… | |
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 Dec 7 17:49:47 2007" /> |
9 | <meta name="created" content="Fri Dec 7 19:03:06 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 --> |
… | |
… | |
917 | this situation even with a relatively standard program structure. Thus |
917 | this situation even with a relatively standard program structure. Thus |
918 | it is best to always use non-blocking I/O: An extra <code>read</code>(2) returning |
918 | it is best to always use non-blocking I/O: An extra <code>read</code>(2) returning |
919 | <code>EAGAIN</code> is far preferable to a program hanging until some data arrives.</p> |
919 | <code>EAGAIN</code> is far preferable to a program hanging until some data arrives.</p> |
920 | <p>If you cannot run the fd in non-blocking mode (for example you should not |
920 | <p>If you cannot run the fd in non-blocking mode (for example you should not |
921 | play around with an Xlib connection), then you have to seperately re-test |
921 | play around with an Xlib connection), then you have to seperately re-test |
922 | wether a file descriptor is really ready with a known-to-be good interface |
922 | whether a file descriptor is really ready with a known-to-be good interface |
923 | such as poll (fortunately in our Xlib example, Xlib already does this on |
923 | such as poll (fortunately in our Xlib example, Xlib already does this on |
924 | its own, so its quite safe to use).</p> |
924 | its own, so its quite safe to use).</p> |
925 | <dl> |
925 | <dl> |
926 | <dt>ev_io_init (ev_io *, callback, int fd, int events)</dt> |
926 | <dt>ev_io_init (ev_io *, callback, int fd, int events)</dt> |
927 | <dt>ev_io_set (ev_io *, int fd, int events)</dt> |
927 | <dt>ev_io_set (ev_io *, int fd, int events)</dt> |
… | |
… | |
1832 | |
1832 | |
1833 | </div> |
1833 | </div> |
1834 | <h1 id="MACRO_MAGIC">MACRO MAGIC</h1> |
1834 | <h1 id="MACRO_MAGIC">MACRO MAGIC</h1> |
1835 | <div id="MACRO_MAGIC_CONTENT"> |
1835 | <div id="MACRO_MAGIC_CONTENT"> |
1836 | <p>Libev can be compiled with a variety of options, the most fundemantal is |
1836 | <p>Libev can be compiled with a variety of options, the most fundemantal is |
1837 | <code>EV_MULTIPLICITY</code>. This option determines wether (most) functions and |
1837 | <code>EV_MULTIPLICITY</code>. This option determines whether (most) functions and |
1838 | callbacks have an initial <code>struct ev_loop *</code> argument.</p> |
1838 | callbacks have an initial <code>struct ev_loop *</code> argument.</p> |
1839 | <p>To make it easier to write programs that cope with either variant, the |
1839 | <p>To make it easier to write programs that cope with either variant, the |
1840 | following macros are defined:</p> |
1840 | following macros are defined:</p> |
1841 | <dl> |
1841 | <dl> |
1842 | <dt><code>EV_A</code>, <code>EV_A_</code></dt> |
1842 | <dt><code>EV_A</code>, <code>EV_A_</code></dt> |
… | |
… | |
1872 | <p>Similar to the other two macros, this gives you the value of the default |
1872 | <p>Similar to the other two macros, this gives you the value of the default |
1873 | loop, if multiple loops are supported ("ev loop default").</p> |
1873 | loop, if multiple loops are supported ("ev loop default").</p> |
1874 | </dd> |
1874 | </dd> |
1875 | </dl> |
1875 | </dl> |
1876 | <p>Example: Declare and initialise a check watcher, utilising the above |
1876 | <p>Example: Declare and initialise a check watcher, utilising the above |
1877 | macros so it will work regardless of wether multiple loops are supported |
1877 | macros so it will work regardless of whether multiple loops are supported |
1878 | or not.</p> |
1878 | or not.</p> |
1879 | <pre> static void |
1879 | <pre> static void |
1880 | check_cb (EV_P_ ev_timer *w, int revents) |
1880 | check_cb (EV_P_ ev_timer *w, int revents) |
1881 | { |
1881 | { |
1882 | ev_check_stop (EV_A_ w); |
1882 | ev_check_stop (EV_A_ w); |