#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; struct eventLoop *el; void *data; void (*handle)(struct event *ev); void (*delete)(struct event *ev); }; 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); #endif