… | |
… | |
726 | |
726 | |
727 | If you have a watcher you never unregister that should not keep C<ev_loop> |
727 | If you have a watcher you never unregister that should not keep C<ev_loop> |
728 | from returning, call ev_unref() after starting, and ev_ref() before |
728 | from returning, call ev_unref() after starting, and ev_ref() before |
729 | stopping it. |
729 | stopping it. |
730 | |
730 | |
731 | As an example, libev itself uses this for its internal signal pipe: It is |
731 | As an example, libev itself uses this for its internal signal pipe: It |
732 | not visible to the libev user and should not keep C<ev_loop> from exiting |
732 | is not visible to the libev user and should not keep C<ev_loop> from |
733 | if no event watchers registered by it are active. It is also an excellent |
733 | exiting if no event watchers registered by it are active. It is also an |
734 | way to do this for generic recurring timers or from within third-party |
734 | excellent way to do this for generic recurring timers or from within |
735 | libraries. Just remember to I<unref after start> and I<ref before stop> |
735 | third-party libraries. Just remember to I<unref after start> and I<ref |
736 | (but only if the watcher wasn't active before, or was active before, |
736 | before stop> (but only if the watcher wasn't active before, or was active |
737 | respectively). |
737 | before, respectively. Note also that libev might stop watchers itself |
|
|
738 | (e.g. non-repeating timers) in which case you have to C<ev_ref> |
|
|
739 | in the callback). |
738 | |
740 | |
739 | Example: Create a signal watcher, but keep it from keeping C<ev_loop> |
741 | Example: Create a signal watcher, but keep it from keeping C<ev_loop> |
740 | running when nothing else is active. |
742 | running when nothing else is active. |
741 | |
743 | |
742 | ev_signal exitsig; |
744 | ev_signal exitsig; |
… | |
… | |
925 | C<ev_fork>). |
927 | C<ev_fork>). |
926 | |
928 | |
927 | =item C<EV_ASYNC> |
929 | =item C<EV_ASYNC> |
928 | |
930 | |
929 | The given async watcher has been asynchronously notified (see C<ev_async>). |
931 | The given async watcher has been asynchronously notified (see C<ev_async>). |
|
|
932 | |
|
|
933 | =item C<EV_CUSTOM> |
|
|
934 | |
|
|
935 | Not ever sent (or otherwise used) by libev itself, but can be freely used |
|
|
936 | by libev users to signal watchers (e.g. via C<ev_feed_event>). |
930 | |
937 | |
931 | =item C<EV_ERROR> |
938 | =item C<EV_ERROR> |
932 | |
939 | |
933 | An unspecified error has occurred, the watcher has been stopped. This might |
940 | An unspecified error has occurred, the watcher has been stopped. This might |
934 | happen because the watcher could not be properly started because libev |
941 | happen because the watcher could not be properly started because libev |