aboutsummaryrefslogtreecommitdiff
path: root/eventloop.h
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-12-02 01:04:51 +0800
committerGuangxiong Lin <[email protected]>2022-12-02 01:04:51 +0800
commit14eb75c7f5e90f3c1174cdf700753d74bbd358a8 (patch)
tree33954c3ad8e10ac381f4b5d48c5bf541e061199d /eventloop.h
parent9bed42bfcdb548c2f097a7536d3fa6a4117b57e9 (diff)
downloadtinyserver-14eb75c7f5e90f3c1174cdf700753d74bbd358a8.tar.gz
tinyserver-14eb75c7f5e90f3c1174cdf700753d74bbd358a8.tar.bz2
tinyserver-14eb75c7f5e90f3c1174cdf700753d74bbd358a8.zip
Abstract accept and handle as event
Diffstat (limited to 'eventloop.h')
-rw-r--r--eventloop.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/eventloop.h b/eventloop.h
index 4dd7f6e..490d515 100644
--- a/eventloop.h
+++ b/eventloop.h
@@ -13,9 +13,19 @@ struct eventLoop {
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 eventLoopAddSocket(struct eventLoop *el, struct tsocket *sock, int flag);
int eventLoopWait(struct eventLoop *el, int timeout);
-struct tsocket *eventLoopGetSocket(struct eventLoop *el, int index);
+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