… | |
… | |
298 | If you don't know what event loop to use, use the one returned from this |
298 | If you don't know what event loop to use, use the one returned from this |
299 | function. |
299 | function. |
300 | |
300 | |
301 | Note that this function is I<not> thread-safe, so if you want to use it |
301 | Note that this function is I<not> thread-safe, so if you want to use it |
302 | from multiple threads, you have to lock (note also that this is unlikely, |
302 | from multiple threads, you have to lock (note also that this is unlikely, |
303 | as loops cannot bes hared easily between threads anyway). |
303 | as loops cannot be shared easily between threads anyway). |
304 | |
304 | |
305 | The default loop is the only loop that can handle C<ev_signal> and |
305 | The default loop is the only loop that can handle C<ev_signal> and |
306 | C<ev_child> watchers, and to do this, it always registers a handler |
306 | C<ev_child> watchers, and to do this, it always registers a handler |
307 | for C<SIGCHLD>. If this is a problem for your application you can either |
307 | for C<SIGCHLD>. If this is a problem for your application you can either |
308 | create a dynamic loop with C<ev_loop_new> that doesn't do that, or you |
308 | create a dynamic loop with C<ev_loop_new> that doesn't do that, or you |
… | |
… | |
647 | the loop. |
647 | the loop. |
648 | |
648 | |
649 | A flags value of C<EVLOOP_ONESHOT> will look for new events (waiting if |
649 | A flags value of C<EVLOOP_ONESHOT> will look for new events (waiting if |
650 | necessary) and will handle those and any already outstanding ones. It |
650 | necessary) and will handle those and any already outstanding ones. It |
651 | will block your process until at least one new event arrives (which could |
651 | will block your process until at least one new event arrives (which could |
652 | be an event internal to libev itself, so there is no guarentee that a |
652 | be an event internal to libev itself, so there is no guarantee that a |
653 | user-registered callback will be called), and will return after one |
653 | user-registered callback will be called), and will return after one |
654 | iteration of the loop. |
654 | iteration of the loop. |
655 | |
655 | |
656 | This is useful if you are waiting for some external event in conjunction |
656 | This is useful if you are waiting for some external event in conjunction |
657 | with something not expressible using other libev watchers (i.e. "roll your |
657 | with something not expressible using other libev watchers (i.e. "roll your |
… | |
… | |
1943 | to see if it changed somehow. You can specify a recommended polling |
1943 | to see if it changed somehow. You can specify a recommended polling |
1944 | interval for this case. If you specify a polling interval of C<0> (highly |
1944 | interval for this case. If you specify a polling interval of C<0> (highly |
1945 | recommended!) then a I<suitable, unspecified default> value will be used |
1945 | recommended!) then a I<suitable, unspecified default> value will be used |
1946 | (which you can expect to be around five seconds, although this might |
1946 | (which you can expect to be around five seconds, although this might |
1947 | change dynamically). Libev will also impose a minimum interval which is |
1947 | change dynamically). Libev will also impose a minimum interval which is |
1948 | currently around C<0.1>, but thats usually overkill. |
1948 | currently around C<0.1>, but that's usually overkill. |
1949 | |
1949 | |
1950 | This watcher type is not meant for massive numbers of stat watchers, |
1950 | This watcher type is not meant for massive numbers of stat watchers, |
1951 | as even with OS-supported change notifications, this can be |
1951 | as even with OS-supported change notifications, this can be |
1952 | resource-intensive. |
1952 | resource-intensive. |
1953 | |
1953 | |
… | |
… | |
2643 | =over 4 |
2643 | =over 4 |
2644 | |
2644 | |
2645 | =item ev_async_init (ev_async *, callback) |
2645 | =item ev_async_init (ev_async *, callback) |
2646 | |
2646 | |
2647 | Initialises and configures the async watcher - it has no parameters of any |
2647 | Initialises and configures the async watcher - it has no parameters of any |
2648 | kind. There is a C<ev_asynd_set> macro, but using it is utterly pointless, |
2648 | kind. There is a C<ev_async_set> macro, but using it is utterly pointless, |
2649 | trust me. |
2649 | trust me. |
2650 | |
2650 | |
2651 | =item ev_async_send (loop, ev_async *) |
2651 | =item ev_async_send (loop, ev_async *) |
2652 | |
2652 | |
2653 | Sends/signals/activates the given C<ev_async> watcher, that is, feeds |
2653 | Sends/signals/activates the given C<ev_async> watcher, that is, feeds |
… | |
… | |
3086 | |
3086 | |
3087 | #define EV_STANDALONE 1 |
3087 | #define EV_STANDALONE 1 |
3088 | #include "ev.h" |
3088 | #include "ev.h" |
3089 | |
3089 | |
3090 | Both header files and implementation files can be compiled with a C++ |
3090 | Both header files and implementation files can be compiled with a C++ |
3091 | compiler (at least, thats a stated goal, and breakage will be treated |
3091 | compiler (at least, that's a stated goal, and breakage will be treated |
3092 | as a bug). |
3092 | as a bug). |
3093 | |
3093 | |
3094 | You need the following files in your source tree, or in a directory |
3094 | You need the following files in your source tree, or in a directory |
3095 | in your include path (e.g. in libev/ when using -Ilibev): |
3095 | in your include path (e.g. in libev/ when using -Ilibev): |
3096 | |
3096 | |
… | |
… | |
3568 | loop, as long as you don't confuse yourself). The only exception is that |
3568 | loop, as long as you don't confuse yourself). The only exception is that |
3569 | you must not do this from C<ev_periodic> reschedule callbacks. |
3569 | you must not do this from C<ev_periodic> reschedule callbacks. |
3570 | |
3570 | |
3571 | Care has been taken to ensure that libev does not keep local state inside |
3571 | Care has been taken to ensure that libev does not keep local state inside |
3572 | C<ev_loop>, and other calls do not usually allow for coroutine switches as |
3572 | C<ev_loop>, and other calls do not usually allow for coroutine switches as |
3573 | they do not clal any callbacks. |
3573 | they do not call any callbacks. |
3574 | |
3574 | |
3575 | =head2 COMPILER WARNINGS |
3575 | =head2 COMPILER WARNINGS |
3576 | |
3576 | |
3577 | Depending on your compiler and compiler settings, you might get no or a |
3577 | Depending on your compiler and compiler settings, you might get no or a |
3578 | lot of warnings when compiling libev code. Some people are apparently |
3578 | lot of warnings when compiling libev code. Some people are apparently |
… | |
… | |
3612 | ==2274== definitely lost: 0 bytes in 0 blocks. |
3612 | ==2274== definitely lost: 0 bytes in 0 blocks. |
3613 | ==2274== possibly lost: 0 bytes in 0 blocks. |
3613 | ==2274== possibly lost: 0 bytes in 0 blocks. |
3614 | ==2274== still reachable: 256 bytes in 1 blocks. |
3614 | ==2274== still reachable: 256 bytes in 1 blocks. |
3615 | |
3615 | |
3616 | Then there is no memory leak, just as memory accounted to global variables |
3616 | Then there is no memory leak, just as memory accounted to global variables |
3617 | is not a memleak - the memory is still being refernced, and didn't leak. |
3617 | is not a memleak - the memory is still being referenced, and didn't leak. |
3618 | |
3618 | |
3619 | Similarly, under some circumstances, valgrind might report kernel bugs |
3619 | Similarly, under some circumstances, valgrind might report kernel bugs |
3620 | as if it were a bug in libev (e.g. in realloc or in the poll backend, |
3620 | as if it were a bug in libev (e.g. in realloc or in the poll backend, |
3621 | although an acceptable workaround has been found here), or it might be |
3621 | although an acceptable workaround has been found here), or it might be |
3622 | confused. |
3622 | confused. |