… | |
… | |
342 | Example: Restrict libev to the select and poll backends, and do not allow |
342 | Example: Restrict libev to the select and poll backends, and do not allow |
343 | environment settings to be taken into account: |
343 | environment settings to be taken into account: |
344 | |
344 | |
345 | ev_default_loop (EVBACKEND_POLL | EVBACKEND_SELECT | EVFLAG_NOENV); |
345 | ev_default_loop (EVBACKEND_POLL | EVBACKEND_SELECT | EVFLAG_NOENV); |
346 | |
346 | |
347 | Example: Use whatever libev has to offer, but make sure that kqueue is |
|
|
348 | used if available (warning, breaks stuff, best use only with your own |
|
|
349 | private event loop and only if you know the OS supports your types of |
|
|
350 | fds): |
|
|
351 | |
|
|
352 | ev_default_loop (ev_recommended_backends () | EVBACKEND_KQUEUE); |
|
|
353 | |
|
|
354 | =item struct ev_loop *ev_loop_new (unsigned int flags) |
347 | =item struct ev_loop *ev_loop_new (unsigned int flags) |
355 | |
348 | |
356 | This will create and initialise a new event loop object. If the loop |
349 | This will create and initialise a new event loop object. If the loop |
357 | could not be initialised, returns false. |
350 | could not be initialised, returns false. |
358 | |
351 | |
… | |
… | |
589 | Example: Try to create a event loop that uses epoll and nothing else. |
582 | Example: Try to create a event loop that uses epoll and nothing else. |
590 | |
583 | |
591 | struct ev_loop *epoller = ev_loop_new (EVBACKEND_EPOLL | EVFLAG_NOENV); |
584 | struct ev_loop *epoller = ev_loop_new (EVBACKEND_EPOLL | EVFLAG_NOENV); |
592 | if (!epoller) |
585 | if (!epoller) |
593 | fatal ("no epoll found here, maybe it hides under your chair"); |
586 | fatal ("no epoll found here, maybe it hides under your chair"); |
|
|
587 | |
|
|
588 | Example: Use whatever libev has to offer, but make sure that kqueue is |
|
|
589 | used if available. |
|
|
590 | |
|
|
591 | struct ev_loop *loop = ev_loop_new (ev_recommended_backends () | EVBACKEND_KQUEUE); |
594 | |
592 | |
595 | =item ev_loop_destroy (loop) |
593 | =item ev_loop_destroy (loop) |
596 | |
594 | |
597 | Destroys an event loop object (frees all memory and kernel state |
595 | Destroys an event loop object (frees all memory and kernel state |
598 | etc.). None of the active event watchers will be stopped in the normal |
596 | etc.). None of the active event watchers will be stopped in the normal |