summaryrefslogtreecommitdiff
path: root/adapters/redictmoduleapi.h
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/redictmoduleapi.h')
-rw-r--r--adapters/redictmoduleapi.h122
1 files changed, 61 insertions, 61 deletions
diff --git a/adapters/redictmoduleapi.h b/adapters/redictmoduleapi.h
index 1a134f5..0238ba1 100644
--- a/adapters/redictmoduleapi.h
+++ b/adapters/redictmoduleapi.h
@@ -9,8 +9,8 @@
*
*/
-#ifndef __HIREDIS_REDISMODULEAPI_H__
-#define __HIREDIS_REDISMODULEAPI_H__
+#ifndef __HIREDICT_REDICTMODULEAPI_H__
+#define __HIREDICT_REDICTMODULEAPI_H__
#include "redictmodule.h"
@@ -19,120 +19,120 @@
#include <sys/types.h>
-typedef struct redisModuleEvents {
- redisAsyncContext *context;
- RedisModuleCtx *module_ctx;
+typedef struct redictModuleEvents {
+ redictAsyncContext *context;
+ RedictModuleCtx *module_ctx;
int fd;
int reading, writing;
int timer_active;
- RedisModuleTimerID timer_id;
-} redisModuleEvents;
+ RedictModuleTimerID timer_id;
+} redictModuleEvents;
-static inline void redisModuleReadEvent(int fd, void *privdata, int mask) {
+static inline void redictModuleReadEvent(int fd, void *privdata, int mask) {
(void) fd;
(void) mask;
- redisModuleEvents *e = (redisModuleEvents*)privdata;
- redisAsyncHandleRead(e->context);
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
+ redictAsyncHandleRead(e->context);
}
-static inline void redisModuleWriteEvent(int fd, void *privdata, int mask) {
+static inline void redictModuleWriteEvent(int fd, void *privdata, int mask) {
(void) fd;
(void) mask;
- redisModuleEvents *e = (redisModuleEvents*)privdata;
- redisAsyncHandleWrite(e->context);
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
+ redictAsyncHandleWrite(e->context);
}
-static inline void redisModuleAddRead(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleAddRead(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (!e->reading) {
e->reading = 1;
- RedisModule_EventLoopAdd(e->fd, REDISMODULE_EVENTLOOP_READABLE, redisModuleReadEvent, e);
+ RedictModule_EventLoopAdd(e->fd, REDICTMODULE_EVENTLOOP_READABLE, redictModuleReadEvent, e);
}
}
-static inline void redisModuleDelRead(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleDelRead(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (e->reading) {
e->reading = 0;
- RedisModule_EventLoopDel(e->fd, REDISMODULE_EVENTLOOP_READABLE);
+ RedictModule_EventLoopDel(e->fd, REDICTMODULE_EVENTLOOP_READABLE);
}
}
-static inline void redisModuleAddWrite(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleAddWrite(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (!e->writing) {
e->writing = 1;
- RedisModule_EventLoopAdd(e->fd, REDISMODULE_EVENTLOOP_WRITABLE, redisModuleWriteEvent, e);
+ RedictModule_EventLoopAdd(e->fd, REDICTMODULE_EVENTLOOP_WRITABLE, redictModuleWriteEvent, e);
}
}
-static inline void redisModuleDelWrite(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleDelWrite(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (e->writing) {
e->writing = 0;
- RedisModule_EventLoopDel(e->fd, REDISMODULE_EVENTLOOP_WRITABLE);
+ RedictModule_EventLoopDel(e->fd, REDICTMODULE_EVENTLOOP_WRITABLE);
}
}
-static inline void redisModuleStopTimer(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleStopTimer(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (e->timer_active) {
- RedisModule_StopTimer(e->module_ctx, e->timer_id, NULL);
+ RedictModule_StopTimer(e->module_ctx, e->timer_id, NULL);
}
e->timer_active = 0;
}
-static inline void redisModuleCleanup(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
- redisModuleDelRead(privdata);
- redisModuleDelWrite(privdata);
- redisModuleStopTimer(privdata);
+static inline void redictModuleCleanup(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
+ redictModuleDelRead(privdata);
+ redictModuleDelWrite(privdata);
+ redictModuleStopTimer(privdata);
hi_free(e);
}
-static inline void redisModuleTimeout(RedisModuleCtx *ctx, void *privdata) {
+static inline void redictModuleTimeout(RedictModuleCtx *ctx, void *privdata) {
(void) ctx;
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
e->timer_active = 0;
- redisAsyncHandleTimeout(e->context);
+ redictAsyncHandleTimeout(e->context);
}
-static inline void redisModuleSetTimeout(void *privdata, struct timeval tv) {
- redisModuleEvents* e = (redisModuleEvents*)privdata;
+static inline void redictModuleSetTimeout(void *privdata, struct timeval tv) {
+ redictModuleEvents* e = (redictModuleEvents*)privdata;
- redisModuleStopTimer(privdata);
+ redictModuleStopTimer(privdata);
mstime_t millis = tv.tv_sec * 1000 + tv.tv_usec / 1000.0;
- e->timer_id = RedisModule_CreateTimer(e->module_ctx, millis, redisModuleTimeout, e);
+ e->timer_id = RedictModule_CreateTimer(e->module_ctx, millis, redictModuleTimeout, e);
e->timer_active = 1;
}
-/* Check if Redis version is compatible with the adapter. */
-static inline int redisModuleCompatibilityCheck(void) {
- if (!RedisModule_EventLoopAdd ||
- !RedisModule_EventLoopDel ||
- !RedisModule_CreateTimer ||
- !RedisModule_StopTimer) {
- return REDIS_ERR;
+/* Check if Redict is compatible with the adapter. */
+static inline int redictModuleCompatibilityCheck(void) {
+ if (!RedictModule_EventLoopAdd ||
+ !RedictModule_EventLoopDel ||
+ !RedictModule_CreateTimer ||
+ !RedictModule_StopTimer) {
+ return REDICT_ERR;
}
- return REDIS_OK;
+ return REDICT_OK;
}
-static inline int redisModuleAttach(redisAsyncContext *ac, RedisModuleCtx *module_ctx) {
- redisContext *c = &(ac->c);
- redisModuleEvents *e;
+static inline int redictModuleAttach(redictAsyncContext *ac, RedictModuleCtx *module_ctx) {
+ redictContext *c = &(ac->c);
+ redictModuleEvents *e;
/* Nothing should be attached when something is already attached */
if (ac->ev.data != NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
/* Create container for context and r/w events */
- e = (redisModuleEvents*)hi_malloc(sizeof(*e));
+ e = (redictModuleEvents*)hi_malloc(sizeof(*e));
if (e == NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
e->context = ac;
e->module_ctx = module_ctx;
@@ -141,15 +141,15 @@ static inline int redisModuleAttach(redisAsyncContext *ac, RedisModuleCtx *modul
e->timer_active = 0;
/* Register functions to start/stop listening for events */
- ac->ev.addRead = redisModuleAddRead;
- ac->ev.delRead = redisModuleDelRead;
- ac->ev.addWrite = redisModuleAddWrite;
- ac->ev.delWrite = redisModuleDelWrite;
- ac->ev.cleanup = redisModuleCleanup;
- ac->ev.scheduleTimer = redisModuleSetTimeout;
+ ac->ev.addRead = redictModuleAddRead;
+ ac->ev.delRead = redictModuleDelRead;
+ ac->ev.addWrite = redictModuleAddWrite;
+ ac->ev.delWrite = redictModuleDelWrite;
+ ac->ev.cleanup = redictModuleCleanup;
+ ac->ev.scheduleTimer = redictModuleSetTimeout;
ac->ev.data = e;
- return REDIS_OK;
+ return REDICT_OK;
}
#endif