… | |
… | |
275 | flags. If that is troubling you, check C<ev_backend ()> afterwards). |
275 | flags. If that is troubling you, check C<ev_backend ()> afterwards). |
276 | |
276 | |
277 | If you don't know what event loop to use, use the one returned from this |
277 | If you don't know what event loop to use, use the one returned from this |
278 | function. |
278 | function. |
279 | |
279 | |
|
|
280 | Note that this function is I<not> thread-safe, so if you want to use it |
|
|
281 | from multiple threads, you have to lock (note also that this is unlikely, |
|
|
282 | as loops cannot bes hared easily between threads anyway). |
|
|
283 | |
280 | The default loop is the only loop that can handle C<ev_signal> and |
284 | The default loop is the only loop that can handle C<ev_signal> and |
281 | C<ev_child> watchers, and to do this, it always registers a handler |
285 | C<ev_child> watchers, and to do this, it always registers a handler |
282 | for C<SIGCHLD>. If this is a problem for your app you can either |
286 | for C<SIGCHLD>. If this is a problem for your app you can either |
283 | create a dynamic loop with C<ev_loop_new> that doesn't do that, or you |
287 | create a dynamic loop with C<ev_loop_new> that doesn't do that, or you |
284 | can simply overwrite the C<SIGCHLD> signal handler I<after> calling |
288 | can simply overwrite the C<SIGCHLD> signal handler I<after> calling |
… | |
… | |
465 | |
469 | |
466 | Similar to C<ev_default_loop>, but always creates a new event loop that is |
470 | Similar to C<ev_default_loop>, but always creates a new event loop that is |
467 | always distinct from the default loop. Unlike the default loop, it cannot |
471 | always distinct from the default loop. Unlike the default loop, it cannot |
468 | handle signal and child watchers, and attempts to do so will be greeted by |
472 | handle signal and child watchers, and attempts to do so will be greeted by |
469 | undefined behaviour (or a failed assertion if assertions are enabled). |
473 | undefined behaviour (or a failed assertion if assertions are enabled). |
|
|
474 | |
|
|
475 | Note that this function I<is> thread-safe, and the recommended way to use |
|
|
476 | libev with threads is indeed to create one loop per thread, and using the |
|
|
477 | default loop in the "main" or "initial" thread. |
470 | |
478 | |
471 | Example: Try to create a event loop that uses epoll and nothing else. |
479 | Example: Try to create a event loop that uses epoll and nothing else. |
472 | |
480 | |
473 | struct ev_loop *epoller = ev_loop_new (EVBACKEND_EPOLL | EVFLAG_NOENV); |
481 | struct ev_loop *epoller = ev_loop_new (EVBACKEND_EPOLL | EVFLAG_NOENV); |
474 | if (!epoller) |
482 | if (!epoller) |