… | |
… | |
883 | it is best to always use non-blocking I/O: An extra C<read>(2) returning |
883 | it is best to always use non-blocking I/O: An extra C<read>(2) returning |
884 | C<EAGAIN> is far preferable to a program hanging until some data arrives. |
884 | C<EAGAIN> is far preferable to a program hanging until some data arrives. |
885 | |
885 | |
886 | If you cannot run the fd in non-blocking mode (for example you should not |
886 | If you cannot run the fd in non-blocking mode (for example you should not |
887 | play around with an Xlib connection), then you have to seperately re-test |
887 | play around with an Xlib connection), then you have to seperately re-test |
888 | wether a file descriptor is really ready with a known-to-be good interface |
888 | whether a file descriptor is really ready with a known-to-be good interface |
889 | such as poll (fortunately in our Xlib example, Xlib already does this on |
889 | such as poll (fortunately in our Xlib example, Xlib already does this on |
890 | its own, so its quite safe to use). |
890 | its own, so its quite safe to use). |
891 | |
891 | |
892 | =over 4 |
892 | =over 4 |
893 | |
893 | |
… | |
… | |
1844 | |
1844 | |
1845 | |
1845 | |
1846 | =head1 MACRO MAGIC |
1846 | =head1 MACRO MAGIC |
1847 | |
1847 | |
1848 | Libev can be compiled with a variety of options, the most fundemantal is |
1848 | Libev can be compiled with a variety of options, the most fundemantal is |
1849 | C<EV_MULTIPLICITY>. This option determines wether (most) functions and |
1849 | C<EV_MULTIPLICITY>. This option determines whether (most) functions and |
1850 | callbacks have an initial C<struct ev_loop *> argument. |
1850 | callbacks have an initial C<struct ev_loop *> argument. |
1851 | |
1851 | |
1852 | To make it easier to write programs that cope with either variant, the |
1852 | To make it easier to write programs that cope with either variant, the |
1853 | following macros are defined: |
1853 | following macros are defined: |
1854 | |
1854 | |
… | |
… | |
1888 | loop, if multiple loops are supported ("ev loop default"). |
1888 | loop, if multiple loops are supported ("ev loop default"). |
1889 | |
1889 | |
1890 | =back |
1890 | =back |
1891 | |
1891 | |
1892 | Example: Declare and initialise a check watcher, utilising the above |
1892 | Example: Declare and initialise a check watcher, utilising the above |
1893 | macros so it will work regardless of wether multiple loops are supported |
1893 | macros so it will work regardless of whether multiple loops are supported |
1894 | or not. |
1894 | or not. |
1895 | |
1895 | |
1896 | static void |
1896 | static void |
1897 | check_cb (EV_P_ ev_timer *w, int revents) |
1897 | check_cb (EV_P_ ev_timer *w, int revents) |
1898 | { |
1898 | { |