aboutsummaryrefslogtreecommitdiff
path: root/eventloop.h
blob: 39c05d5482a6b31681349125debb6422200c2d11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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