X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/ed9b544e10b84cd43348ddfab7068b610a5df1f7..03a37888f6581ec46d5eaee8c77b18b7926d2ca3:/ae.h diff --git a/ae.h b/ae.h index 69bbbee9..0a056ce9 100644 --- a/ae.h +++ b/ae.h @@ -33,6 +33,26 @@ #ifndef __AE_H__ #define __AE_H__ +#define AE_SETSIZE (1024*10) /* Max number of fd supported */ + +#define AE_OK 0 +#define AE_ERR -1 + +#define AE_NONE 0 +#define AE_READABLE 1 +#define AE_WRITABLE 2 +#define AE_EXCEPTION 4 + +#define AE_FILE_EVENTS 1 +#define AE_TIME_EVENTS 2 +#define AE_ALL_EVENTS (AE_FILE_EVENTS|AE_TIME_EVENTS) +#define AE_DONT_WAIT 4 + +#define AE_NOMORE -1 + +/* Macros */ +#define AE_NOTUSED(V) ((void) V) + struct aeEventLoop; /* Types and data structures */ @@ -42,12 +62,11 @@ typedef void aeEventFinalizerProc(struct aeEventLoop *eventLoop, void *clientDat /* File event structure */ typedef struct aeFileEvent { - int fd; int mask; /* one of AE_(READABLE|WRITABLE|EXCEPTION) */ - aeFileProc *fileProc; - aeEventFinalizerProc *finalizerProc; + aeFileProc *rfileProc; + aeFileProc *wfileProc; + aeFileProc *efileProc; void *clientData; - struct aeFileEvent *next; } aeFileEvent; /* Time event structure */ @@ -61,39 +80,29 @@ typedef struct aeTimeEvent { struct aeTimeEvent *next; } aeTimeEvent; +/* A fired event */ +typedef struct aeFiredEvent { + int fd; + int mask; +} aeFiredEvent; + /* State of an event based program */ typedef struct aeEventLoop { + int maxfd; long long timeEventNextId; - aeFileEvent *fileEventHead; + aeFileEvent events[AE_SETSIZE]; /* Registered events */ + aeFiredEvent fired[AE_SETSIZE]; /* Fired events */ aeTimeEvent *timeEventHead; int stop; + void *apidata; /* This is used for polling API specific data */ } aeEventLoop; -/* Defines */ -#define AE_OK 0 -#define AE_ERR -1 - -#define AE_READABLE 1 -#define AE_WRITABLE 2 -#define AE_EXCEPTION 4 - -#define AE_FILE_EVENTS 1 -#define AE_TIME_EVENTS 2 -#define AE_ALL_EVENTS (AE_FILE_EVENTS|AE_TIME_EVENTS) -#define AE_DONT_WAIT 4 - -#define AE_NOMORE -1 - -/* Macros */ -#define AE_NOTUSED(V) ((void) V) - /* Prototypes */ aeEventLoop *aeCreateEventLoop(void); void aeDeleteEventLoop(aeEventLoop *eventLoop); void aeStop(aeEventLoop *eventLoop); int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask, - aeFileProc *proc, void *clientData, - aeEventFinalizerProc *finalizerProc); + aeFileProc *proc, void *clientData); void aeDeleteFileEvent(aeEventLoop *eventLoop, int fd, int mask); long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds, aeTimeProc *proc, void *clientData, @@ -102,5 +111,6 @@ int aeDeleteTimeEvent(aeEventLoop *eventLoop, long long id); int aeProcessEvents(aeEventLoop *eventLoop, int flags); int aeWait(int fd, int mask, long long milliseconds); void aeMain(aeEventLoop *eventLoop); +char *aeGetApiName(void); #endif