diff options
Diffstat (limited to 'adapters/libev.h')
-rw-r--r-- | adapters/libev.h | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/adapters/libev.h b/adapters/libev.h index 9e28bc4..8a2a4f3 100644 --- a/adapters/libev.h +++ b/adapters/libev.h @@ -10,47 +10,63 @@ typedef struct redisLibevEvents { ev_io rev, wev; } redisLibevEvents; -void redisLibevReadEvent(struct ev_loop *loop, ev_io *watcher, int revents) { - ((void)loop); ((void)revents); +void redisLibevReadEvent(EV_P_ ev_io *watcher, int revents) { +#if EV_MULTIPLICITY + ((void)loop); +#endif + ((void)revents); + redisLibevEvents *e = (redisLibevEvents*)watcher->data; redisAsyncHandleRead(e->context); } -void redisLibevWriteEvent(struct ev_loop *loop, ev_io *watcher, int revents) { - ((void)loop); ((void)revents); +void redisLibevWriteEvent(EV_P_ ev_io *watcher, int revents) { +#if EV_MULTIPLICITY + ((void)loop); +#endif + ((void)revents); + redisLibevEvents *e = (redisLibevEvents*)watcher->data; redisAsyncHandleWrite(e->context); } void redisLibevAddRead(void *privdata) { redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); if (!e->reading) { e->reading = 1; - ev_io_start(e->loop,&e->rev); + ev_io_start(EV_A_ &e->rev); } } void redisLibevDelRead(void *privdata) { redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); if (e->reading) { e->reading = 0; - ev_io_stop(e->loop,&e->rev); + ev_io_stop(EV_A_ &e->rev); } } void redisLibevAddWrite(void *privdata) { redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); if (!e->writing) { e->writing = 1; - ev_io_start(e->loop,&e->wev); + ev_io_start(EV_A_ &e->wev); } } void redisLibevDelWrite(void *privdata) { redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); if (e->writing) { e->writing = 0; - ev_io_stop(e->loop,&e->wev); + ev_io_stop(EV_A_ &e->wev); } } @@ -61,7 +77,7 @@ void redisLibevCleanup(void *privdata) { free(e); } -int redisLibevAttach(redisAsyncContext *ac, struct ev_loop *loop) { +int redisLibevAttach(EV_P_ redisAsyncContext *ac) { redisContext *c = &(ac->c); redisLibevEvents *e; @@ -72,7 +88,11 @@ int redisLibevAttach(redisAsyncContext *ac, struct ev_loop *loop) { /* Create container for context and r/w events */ e = (redisLibevEvents*)malloc(sizeof(*e)); e->context = ac; +#if EV_MULTIPLICITY e->loop = loop; +#else + e->loop = NULL; +#endif e->reading = e->writing = 0; e->rev.data = e; e->wev.data = e; |