… | |
… | |
774 | =item C<EV_FORK> |
774 | =item C<EV_FORK> |
775 | |
775 | |
776 | The event loop has been resumed in the child process after fork (see |
776 | The event loop has been resumed in the child process after fork (see |
777 | C<ev_fork>). |
777 | C<ev_fork>). |
778 | |
778 | |
|
|
779 | =item C<EV_ASYNC> |
|
|
780 | |
|
|
781 | The given async watcher has been asynchronously notified (see C<ev_async>). |
|
|
782 | |
779 | =item C<EV_ERROR> |
783 | =item C<EV_ERROR> |
780 | |
784 | |
781 | An unspecified error has occured, the watcher has been stopped. This might |
785 | An unspecified error has occured, the watcher has been stopped. This might |
782 | happen because the watcher could not be properly started because libev |
786 | happen because the watcher could not be properly started because libev |
783 | ran out of memory, a file descriptor was found to be closed or any other |
787 | ran out of memory, a file descriptor was found to be closed or any other |
… | |
… | |
2046 | believe me. |
2050 | believe me. |
2047 | |
2051 | |
2048 | =back |
2052 | =back |
2049 | |
2053 | |
2050 | |
2054 | |
|
|
2055 | =head2 C<ev_async> - how to wake up another event loop |
|
|
2056 | |
|
|
2057 | In general, you cannot use an C<ev_loop> from multiple threads or other |
|
|
2058 | asynchronous sources such as signal handlers (as opposed to multiple event |
|
|
2059 | loops - those are of course safe to use in different threads). |
|
|
2060 | |
|
|
2061 | Sometimes, however, you need to wake up another event loop you do not |
|
|
2062 | control, for example because it belongs to another thread. This is what |
|
|
2063 | C<ev_async> watchers do: as long as the C<ev_async> watcher is active, you |
|
|
2064 | can signal it by calling C<ev_async_send>, which is thread- and signal |
|
|
2065 | safe. |
|
|
2066 | |
|
|
2067 | This functionality is very similar to C<ev_signal> watchers, as signals, |
|
|
2068 | too, are asynchronous in nature, and signals, too, will be compressed |
|
|
2069 | (i.e. the number of callback invocations may be less than the number of |
|
|
2070 | C<ev_async_sent> calls). |
|
|
2071 | |
|
|
2072 | Unlike C<ev_signal> watchers, C<ev_async> works with any event loop, not |
|
|
2073 | just the default loop. |
|
|
2074 | |
|
|
2075 | =head3 Watcher-Specific Functions and Data Members |
|
|
2076 | |
|
|
2077 | =over 4 |
|
|
2078 | |
|
|
2079 | =item ev_async_init (ev_async *, callback) |
|
|
2080 | |
|
|
2081 | Initialises and configures the async watcher - it has no parameters of any |
|
|
2082 | kind. There is a C<ev_asynd_set> macro, but using it is utterly pointless, |
|
|
2083 | believe me. |
|
|
2084 | |
|
|
2085 | =item ev_async_send (loop, ev_async *) |
|
|
2086 | |
|
|
2087 | Sends/signals/activates the given C<ev_async> watcher, that is, feeds |
|
|
2088 | an C<EV_ASYNC> event on the watcher into the event loop. Unlike |
|
|
2089 | C<ev_feed_event>, this call is safe to do in other threads, signal or |
|
|
2090 | similar contexts (see the dicusssion of C<EV_ATOMIC_T> in the embedding |
|
|
2091 | section below on what exactly this means). |
|
|
2092 | |
|
|
2093 | This call incurs the overhead of a syscall only once per loop iteration, |
|
|
2094 | so while the overhead might be noticable, it doesn't apply to repeated |
|
|
2095 | calls to C<ev_async_send>. |
|
|
2096 | |
|
|
2097 | =back |
|
|
2098 | |
|
|
2099 | |
2051 | =head1 OTHER FUNCTIONS |
2100 | =head1 OTHER FUNCTIONS |
2052 | |
2101 | |
2053 | There are some other functions of possible interest. Described. Here. Now. |
2102 | There are some other functions of possible interest. Described. Here. Now. |
2054 | |
2103 | |
2055 | =over 4 |
2104 | =over 4 |