… | |
… | |
685 | C<EVUNLOOP_ONE>, which will make the innermost C<ev_loop> call return, or |
685 | C<EVUNLOOP_ONE>, which will make the innermost C<ev_loop> call return, or |
686 | C<EVUNLOOP_ALL>, which will make all nested C<ev_loop> calls return. |
686 | C<EVUNLOOP_ALL>, which will make all nested C<ev_loop> calls return. |
687 | |
687 | |
688 | This "unloop state" will be cleared when entering C<ev_loop> again. |
688 | This "unloop state" will be cleared when entering C<ev_loop> again. |
689 | |
689 | |
|
|
690 | It is safe to call C<ev_unloop> from otuside any C<ev_loop> calls. |
|
|
691 | |
690 | =item ev_ref (loop) |
692 | =item ev_ref (loop) |
691 | |
693 | |
692 | =item ev_unref (loop) |
694 | =item ev_unref (loop) |
693 | |
695 | |
694 | Ref/unref can be used to add or remove a reference count on the event |
696 | Ref/unref can be used to add or remove a reference count on the event |
… | |
… | |
967 | |
969 | |
968 | ev_io_start (EV_DEFAULT_UC, &w); |
970 | ev_io_start (EV_DEFAULT_UC, &w); |
969 | |
971 | |
970 | =item C<ev_TYPE_stop> (loop *, ev_TYPE *watcher) |
972 | =item C<ev_TYPE_stop> (loop *, ev_TYPE *watcher) |
971 | |
973 | |
972 | Stops the given watcher again (if active) and clears the pending |
974 | Stops the given watcher if active, and clears the pending status (whether |
|
|
975 | the watcher was active or not). |
|
|
976 | |
973 | status. It is possible that stopped watchers are pending (for example, |
977 | It is possible that stopped watchers are pending - for example, |
974 | non-repeating timers are being stopped when they become pending), but |
978 | non-repeating timers are being stopped when they become pending - but |
975 | C<ev_TYPE_stop> ensures that the watcher is neither active nor pending. If |
979 | calling C<ev_TYPE_stop> ensures that the watcher is neither active nor |
976 | you want to free or reuse the memory used by the watcher it is therefore a |
980 | pending. If you want to free or reuse the memory used by the watcher it is |
977 | good idea to always call its C<ev_TYPE_stop> function. |
981 | therefore a good idea to always call its C<ev_TYPE_stop> function. |
978 | |
982 | |
979 | =item bool ev_is_active (ev_TYPE *watcher) |
983 | =item bool ev_is_active (ev_TYPE *watcher) |
980 | |
984 | |
981 | Returns a true value iff the watcher is active (i.e. it has been started |
985 | Returns a true value iff the watcher is active (i.e. it has been started |
982 | and not yet been stopped). As long as a watcher is active you must not modify |
986 | and not yet been stopped). As long as a watcher is active you must not modify |
… | |
… | |
1792 | to exchange stat structures with application programs compiled using the |
1796 | to exchange stat structures with application programs compiled using the |
1793 | default compilation environment. |
1797 | default compilation environment. |
1794 | |
1798 | |
1795 | =head3 Inotify and Kqueue |
1799 | =head3 Inotify and Kqueue |
1796 | |
1800 | |
1797 | When C<inotify (7)> support has been compiled into libev (generally only |
1801 | When C<inotify (7)> support has been compiled into libev (generally |
|
|
1802 | only available with Linux 2.6.25 or above due to bugs in earlier |
1798 | available with Linux) and present at runtime, it will be used to speed up |
1803 | implementations) and present at runtime, it will be used to speed up |
1799 | change detection where possible. The inotify descriptor will be created lazily |
1804 | change detection where possible. The inotify descriptor will be created |
1800 | when the first C<ev_stat> watcher is being started. |
1805 | lazily when the first C<ev_stat> watcher is being started. |
1801 | |
1806 | |
1802 | Inotify presence does not change the semantics of C<ev_stat> watchers |
1807 | Inotify presence does not change the semantics of C<ev_stat> watchers |
1803 | except that changes might be detected earlier, and in some cases, to avoid |
1808 | except that changes might be detected earlier, and in some cases, to avoid |
1804 | making regular C<stat> calls. Even in the presence of inotify support |
1809 | making regular C<stat> calls. Even in the presence of inotify support |
1805 | there are many cases where libev has to resort to regular C<stat> polling, |
1810 | there are many cases where libev has to resort to regular C<stat> polling, |
… | |
… | |
2513 | C<events> argument is being ignored. Otherwise, an C<ev_io> watcher for |
2518 | 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. |
2519 | the given C<fd> and C<events> set will be created and started. |
2515 | |
2520 | |
2516 | If C<timeout> is less than 0, then no timeout watcher will be |
2521 | 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 |
2522 | 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 |
2523 | repeat = 0) will be started. C<0> is a valid timeout. |
2519 | dubious value. |
|
|
2520 | |
2524 | |
2521 | The callback has the type C<void (*cb)(int revents, void *arg)> and gets |
2525 | 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 |
2526 | 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> |
2527 | C<EV_ERROR>, C<EV_READ>, C<EV_WRITE> or C<EV_TIMEOUT>) and the C<arg> |
2524 | value passed to C<ev_once>: |
2528 | value passed to C<ev_once>. Note that it is possible to receive I<both> |
|
|
2529 | a timeout and an io event at the same time - you probably should give io |
|
|
2530 | events precedence. |
|
|
2531 | |
|
|
2532 | Example: wait up to ten seconds for data to appear on STDIN_FILENO. |
2525 | |
2533 | |
2526 | static void stdin_ready (int revents, void *arg) |
2534 | static void stdin_ready (int revents, void *arg) |
2527 | { |
2535 | { |
|
|
2536 | if (revents & EV_READ) |
|
|
2537 | /* stdin might have data for us, joy! */; |
2528 | if (revents & EV_TIMEOUT) |
2538 | else if (revents & EV_TIMEOUT) |
2529 | /* doh, nothing entered */; |
2539 | /* doh, nothing entered */; |
2530 | else if (revents & EV_READ) |
|
|
2531 | /* stdin might have data for us, joy! */; |
|
|
2532 | } |
2540 | } |
2533 | |
2541 | |
2534 | ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0); |
2542 | ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0); |
2535 | |
2543 | |
2536 | =item ev_feed_event (ev_loop *, watcher *, int revents) |
2544 | =item ev_feed_event (ev_loop *, watcher *, int revents) |