diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-11-23 15:55:27 +0100 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-11-23 15:55:32 +0100 |
commit | fb49cd19887e45e1118b9a3b09f582305c842e4b (patch) | |
tree | 28e48a56f2ab274896b834cdefd2ca4d1d6c7f8c /adapters | |
parent | 808e43e16179d971fb7faaf5b79588f6abd0689c (diff) |
Make the libev adapter work without support for multiple event loops
Diffstat (limited to 'adapters')
-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; |