mirror of
https://github.com/troglobit/libuev.git
synced 2026-11-11 16:40:35 +00:00
1 parent
e681657ca7
commit
78d140f310
1 file changed
+19
-23
@@ -49,35 +49,31 @@ events: I/O (files, sockets, message queues, etc.), timers, and
|
|||||||
signals.
|
signals.
|
||||||
|
|
||||||
```C
|
```C
|
||||||
/* Event loop functions */
|
/* Callback definition, arg is the same arg as passed to below *_init() */
|
||||||
int uev_init (uev_ctx_t *ctx);
|
typedef void (uev_cb_t)(uev_ctx_t *ctx, uev_t *w, void *arg, int events);
|
||||||
int uev_exit (uev_ctx_t *ctx);
|
|
||||||
int uev_run (uev_ctx_t *ctx, int flags); /* UEV_ONCE, UEV_NONBLOCK, or zero(0) */
|
|
||||||
|
|
||||||
/* Event callback definition, arg is the same arg as passed to below *_init() functions */
|
/* Event loop functions */
|
||||||
typedef void (uev_cb_t)(uev_ctx_t *ctx, uev_t *w, void *arg, int events);
|
int uev_init (uev_ctx_t *ctx);
|
||||||
|
int uev_exit (uev_ctx_t *ctx);
|
||||||
|
int uev_run (uev_ctx_t *ctx, int flags); /* UEV_ONCE, UEV_NONBLOCK, or zero(0) */
|
||||||
|
|
||||||
/* I/O watcher, fd is the non-blocking file descriptor, events is UEV_READ and/or UEV_WRITE */
|
/* I/O watcher: fd is non-blocking, events is UEV_READ and/or UEV_WRITE */
|
||||||
int uev_io_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int fd, int events);
|
int uev_io_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int fd, int events);
|
||||||
int uev_io_set (uev_t *w, int fd, int events);
|
int uev_io_set (uev_t *w, int fd, int events);
|
||||||
int uev_io_stop (uev_t *w);
|
int uev_io_stop (uev_t *w);
|
||||||
|
|
||||||
/* Timer watcher, timeout and period in milliseconds */
|
/* Timer watcher: timeout and period in milliseconds */
|
||||||
int uev_timer_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeout, int period);
|
int uev_timer_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeout, int period);
|
||||||
/* Change timer timeout and/or period */
|
int uev_timer_set (uev_t *w, int timeout, int period); /* Change timeout or period */
|
||||||
int uev_timer_set (uev_t *w, int timeout, int period);
|
int uev_timer_stop (uev_t *w); /* Stop a timer */
|
||||||
/* Stop a timer */
|
|
||||||
int uev_timer_stop (uev_t *w);
|
|
||||||
|
|
||||||
/* Signal watcher, signo is the signal to wait for, e.g., SIGTERM */
|
/* Signal watcher: signo is the signal to wait for, e.g., SIGTERM */
|
||||||
int uev_signal_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int signo);
|
int uev_signal_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int signo);
|
||||||
/* Change the signal a watcher waits for */
|
int uev_signal_set (uev_t *w, int signo); /* Change the signal a watcher waits for */
|
||||||
int uev_signal_set (uev_t *w, int signo);
|
int uev_signal_stop(uev_t *w); /* Stop signal watcher */
|
||||||
/* Stop signal watcher */
|
|
||||||
int uev_signal_stop (uev_t *w);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
To be able to setup callbacks to events the developer first need to
|
To be able to set up callbacks to events the developer first need to
|
||||||
create an *event context*, achieved by calling `uev_init()` with a
|
create an *event context*, achieved by calling `uev_init()` with a
|
||||||
pointer to a local `uev_ctx_t` variable.
|
pointer to a local `uev_ctx_t` variable.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user