mirror of
https://github.com/troglobit/libuev.git
synced 2026-11-23 20:21:58 +00:00
API change -- Remove first ctx argument and add event mask to callback
There really does not exist a good reason for us sending a `uev_ctx_t *` pointer as the first argument to event callbacks. If the callback needs to reference the context, it can find the ctx pointer in the `uev_t *w`. This patch removes the first argument from all callbacks and also fixes a slight bug in that the event loop never returned the actual event that triggered the callback! Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
9e7f6865fc
commit
1f9558059a
6 files changed
+30
-24
No files matched your search
@@ -38,6 +38,7 @@
|
||||
#define UEV_NONE 0
|
||||
#define UEV_READ EPOLLIN
|
||||
#define UEV_WRITE EPOLLOUT
|
||||
#define UEV_EVENT_MASK (UEV_READ | UEV_WRITE)
|
||||
|
||||
/* Run flags */
|
||||
#define UEV_ONCE 1
|
||||
@@ -73,7 +74,7 @@ typedef struct uev {
|
||||
int events;
|
||||
|
||||
/* Watcher callback with optional argument */
|
||||
void (*cb)(struct uev *, struct uev *, void *);
|
||||
void (*cb)(struct uev *, void *, int);
|
||||
void *arg;
|
||||
|
||||
/* Timer watchers, time in milliseconds */
|
||||
@@ -85,7 +86,7 @@ typedef struct uev {
|
||||
} uev_t;
|
||||
|
||||
/* Generic callback for watchers */
|
||||
typedef void (uev_cb_t)(uev_ctx_t *ctx, uev_t *w, void *arg, int events);
|
||||
typedef void (uev_cb_t)(uev_t *w, void *arg, int events);
|
||||
|
||||
/* Private methods, do not use directly! */
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user