#include #include "tsocket.h" #ifndef __EVENT_LOOP_H #define __EVENT_LOOP_H #define EVENT_LOOP_MAX_EVENTS 1024 struct eventLoop { int epollfd; struct epoll_event events[EVENT_LOOP_MAX_EVENTS]; int size; }; struct event { int fd; void *data; int (*handle)(void *data); void (*delete)(void *data); }; struct eventLoop *eventLoopNew(); int eventLoopWait(struct eventLoop *el, int timeout); int eventLoopAdd(struct eventLoop *el, struct event *ev, int flag); int eventLoopDel(struct eventLoop *el, struct event *ev); struct event *eventLoopGet(struct eventLoop *el, int index); void eventLoopLoop(struct eventLoop *el); struct event *eventNew(void *data, int fd, void (*handle), void (*delete)); #endif