… | |
… | |
2513 | C<events> argument is being ignored. Otherwise, an C<ev_io> watcher for |
2513 | C<events> argument is being ignored. Otherwise, an C<ev_io> watcher for |
2514 | the given C<fd> and C<events> set will be created and started. |
2514 | the given C<fd> and C<events> set will be created and started. |
2515 | |
2515 | |
2516 | If C<timeout> is less than 0, then no timeout watcher will be |
2516 | If C<timeout> is less than 0, then no timeout watcher will be |
2517 | started. Otherwise an C<ev_timer> watcher with after = C<timeout> (and |
2517 | started. Otherwise an C<ev_timer> watcher with after = C<timeout> (and |
2518 | repeat = 0) will be started. While C<0> is a valid timeout, it is of |
2518 | repeat = 0) will be started. C<0> is a valid timeout. |
2519 | dubious value. |
|
|
2520 | |
2519 | |
2521 | The callback has the type C<void (*cb)(int revents, void *arg)> and gets |
2520 | The callback has the type C<void (*cb)(int revents, void *arg)> and gets |
2522 | passed an C<revents> set like normal event callbacks (a combination of |
2521 | passed an C<revents> set like normal event callbacks (a combination of |
2523 | C<EV_ERROR>, C<EV_READ>, C<EV_WRITE> or C<EV_TIMEOUT>) and the C<arg> |
2522 | C<EV_ERROR>, C<EV_READ>, C<EV_WRITE> or C<EV_TIMEOUT>) and the C<arg> |
2524 | value passed to C<ev_once>: |
2523 | value passed to C<ev_once>. Note that it is possible to receive I<both> |
|
|
2524 | a timeout and an io event at the same time - you probably should give io |
|
|
2525 | events precedence. |
|
|
2526 | |
|
|
2527 | Example: wait up to ten seconds for data to appear on STDIN_FILENO. |
2525 | |
2528 | |
2526 | static void stdin_ready (int revents, void *arg) |
2529 | static void stdin_ready (int revents, void *arg) |
2527 | { |
2530 | { |
|
|
2531 | if (revents & EV_READ) |
|
|
2532 | /* stdin might have data for us, joy! */; |
2528 | if (revents & EV_TIMEOUT) |
2533 | else if (revents & EV_TIMEOUT) |
2529 | /* doh, nothing entered */; |
2534 | /* doh, nothing entered */; |
2530 | else if (revents & EV_READ) |
|
|
2531 | /* stdin might have data for us, joy! */; |
|
|
2532 | } |
2535 | } |
2533 | |
2536 | |
2534 | ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0); |
2537 | ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0); |
2535 | |
2538 | |
2536 | =item ev_feed_event (ev_loop *, watcher *, int revents) |
2539 | =item ev_feed_event (ev_loop *, watcher *, int revents) |