From 0bf22de8e0e49b56b1799229e921a1a19e9a767c Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 30 Dec 2014 21:13:34 +0100 Subject: [PATCH] More API section updates. Signed-off-by: Joachim Nilsson --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cefdcc2..4f3a7ab 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,16 @@ events: I/O (files, sockets, message queues, etc.), timers, and signals. ```C -/* Callback definition, arg is the same arg as passed to below *_init() */ -typedef void (uev_cb_t)(uev_ctx_t *ctx, uev_t *w, void *arg, int events); +/* Callback example, arg is passed from watcher's *_init() + * w->fd holds the file descriptor, events is set by libuEv + * to indicate if any of UEV_READ and/or UEV_WRITE is ready. + */ +void callback(uev_ctx_t *ctx, uev_t *w, void *arg, int events); /* Event loop functions */ 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) */ +int uev_run (uev_ctx_t *ctx, int flags); /* UEV_ONCE, UEV_NONBLOCK, or UEV_NONE(0) */ /* 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); @@ -69,8 +72,8 @@ int uev_timer_stop (uev_t *w); /* Stop a timer */ /* 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_set (uev_t *w, int signo); /* Change the signal a watcher waits for */ -int uev_signal_stop(uev_t *w); /* Stop signal watcher */ +int uev_signal_set (uev_t *w, int signo); /* Change signal to wait for */ +int uev_signal_stop(uev_t *w); /* Stop signal watcher */ ``` To be able to set up callbacks to events the developer first need to