#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 */
/* 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 */
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,