… | |
… | |
43 | |
43 | |
44 | int |
44 | int |
45 | main (void) |
45 | main (void) |
46 | { |
46 | { |
47 | // use the default event loop unless you have special needs |
47 | // use the default event loop unless you have special needs |
48 | ev_loop *loop = ev_default_loop (0); |
48 | struct ev_loop *loop = ev_default_loop (0); |
49 | |
49 | |
50 | // initialise an io watcher, then start it |
50 | // initialise an io watcher, then start it |
51 | // this one will watch for stdin to become readable |
51 | // this one will watch for stdin to become readable |
52 | ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); |
52 | ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); |
53 | ev_io_start (loop, &stdin_watcher); |
53 | ev_io_start (loop, &stdin_watcher); |
… | |
… | |
3215 | |
3215 | |
3216 | If defined to be C<1>, libev will try to use a direct syscall instead |
3216 | If defined to be C<1>, libev will try to use a direct syscall instead |
3217 | of calling the system-provided C<clock_gettime> function. This option |
3217 | of calling the system-provided C<clock_gettime> function. This option |
3218 | exists because on GNU/Linux, C<clock_gettime> is in C<librt>, but C<librt> |
3218 | exists because on GNU/Linux, C<clock_gettime> is in C<librt>, but C<librt> |
3219 | unconditionally pulls in C<libpthread>, slowing down single-threaded |
3219 | unconditionally pulls in C<libpthread>, slowing down single-threaded |
3220 | programs needlessly. Using a direct syscall is slightly slower, because |
3220 | programs needlessly. Using a direct syscall is slightly slower (in |
3221 | no optimised vdso implementation can be used, but avoids the pthread |
3221 | theory), because no optimised vdso implementation can be used, but avoids |
3222 | dependency. Defaults to C<1> on GNU/Linux with glibc 2.x or higher. |
3222 | the pthread dependency. Defaults to C<1> on GNU/Linux with glibc 2.x or |
|
|
3223 | higher, as it simplifies linking (no need for C<-lrt>). |
3223 | |
3224 | |
3224 | =item EV_USE_NANOSLEEP |
3225 | =item EV_USE_NANOSLEEP |
3225 | |
3226 | |
3226 | If defined to be C<1>, libev will assume that C<nanosleep ()> is available |
3227 | If defined to be C<1>, libev will assume that C<nanosleep ()> is available |
3227 | and will use it for delays. Otherwise it will use C<select ()>. |
3228 | and will use it for delays. Otherwise it will use C<select ()>. |