aboutsummaryrefslogtreecommitdiff
path: root/eventloop.h
diff options
context:
space:
mode:
Diffstat (limited to 'eventloop.h')
-rw-r--r--eventloop.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/eventloop.h b/eventloop.h
new file mode 100644
index 0000000..39c05d5
--- /dev/null
+++ b/eventloop.h
@@ -0,0 +1,22 @@
+#include <sys/epoll.h>
+
+#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];
+ struct tsocket *socks[EVENT_LOOP_MAX_EVENTS];
+ int size;
+};
+
+struct eventLoop *eventLoopNew();
+int eventLoopAddSocket(struct eventLoop *el, struct tsocket *sock, int flag);
+int eventLoopWait(struct eventLoop *el, int timeout);
+struct tsocket *eventLoopGetSocket(struct eventLoop *el, int index);
+
+#endif