-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_dispatcher.h
48 lines (34 loc) · 1.14 KB
/
event_dispatcher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef EVENT_DISPATCHER_H
#define EVENT_DISPATCHER_H
#include "event_loop.h"
#include "lib_gutil.h"
#include <poll.h>
#define MAXEVENTS 128
#define POLL_MAX_SIZE 1024
extern struct event_dispatcher_struc epoll_dispatcher;
extern struct event_dispatcher_struc poll_dispatcher;
typedef struct event_dispatcher_struc {
const char* name;
/*init function*/
void* (*init)(event_loop_struc* event_loop);
int (*add)(event_loop_struc* event_loop, channel_struc* channel);
int (*delete)(event_loop_struc* event_loop, channel_struc* channel);
int (*update)(event_loop_struc* event_loop, channel_struc* channel);
int (*dispatch)(event_loop_struc* event_loop, struct timeval* time_val);
void (*clear)(event_loop_struc* event_loop);
} event_dispatcher_struc;
typedef struct epoll_dispatcher_data_struc {
int event_count;
int nfds;
int realloc_copy;
int efd;
struct epoll_event* events;
}epoll_dispatcher_data_struc;
typedef struct poll_dispatcher_data_struc{
int event_count;
int nfds;
int realloc_copy;
struct pollfd* event_set;
struct pollfd* event_set_copy;
}poll_dispatcher_data_struc;
#endif