libuev
|
Micro event loop library. More...
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <sys/epoll.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/signalfd.h>
#include <unistd.h>
#include "uev.h"
Functions | |
int | _uev_watcher_init (uev_ctx_t *ctx, uev_t *w, uev_type_t type, uev_cb_t *cb, void *arg, int fd, int events) |
int | _uev_watcher_start (uev_t *w) |
int | _uev_watcher_stop (uev_t *w) |
int | _uev_watcher_active (uev_t *w) |
int | _uev_watcher_rearm (uev_t *w) |
int | uev_init (uev_ctx_t *ctx) |
Create an event loop context. More... | |
int | uev_init1 (uev_ctx_t *ctx, int maxevents) |
Create an event loop context. More... | |
int | uev_exit (uev_ctx_t *ctx) |
Terminate the event loop. More... | |
int | uev_run (uev_ctx_t *ctx, int flags) |
Start the event loop. More... | |
Micro event loop library.
int uev_exit | ( | uev_ctx_t * | ctx | ) |
Terminate the event loop.
ctx | A valid libuEv context |
errno
set on error. int uev_init | ( | uev_ctx_t * | ctx | ) |
Create an event loop context.
ctx | Pointer to an uev_ctx_t context to be initialized |
This function calls uev_init1() with maxevents
set to UEV_MAX_EVENTS
int uev_init1 | ( | uev_ctx_t * | ctx, |
int | maxevents | ||
) |
Create an event loop context.
ctx | Pointer to an uev_ctx_t context to be initialized |
maxevents | Maximum number of events in event cache [1, 10] |
This function is the same as uev_init() except for the maxevents
argument, max UEV_MAX_EVENTS, which controls the number of events in the event cache returned to the main loop.
In cases where you have multiple events pending in the cache and some event may cause later ones, already sent by the kernel to userspace, to be deleted the pointer returned to the event loop for this later event may be deleted.
There are two ways around this (accessing deleted memory):
maxevents
to 1int uev_run | ( | uev_ctx_t * | ctx, |
int | flags | ||
) |
Start the event loop.
ctx | A valid libuEv context |
flags | A mask of UEV_ONCE and UEV_NONBLOCK, or zero |
With flags
set to UEV_ONCE the event loop returns after the first event has been served, useful for instance to set a timeout on a file descriptor. If flags
also has the UEV_NONBLOCK flag set the event loop will return immediately if no event is pending, useful when run inside another event loop.