1 #ifndef __EVENTPOLL_H_ 2 #define __EVENTPOLL_H_ 3 4 #include "mtcp_api.h" 5 #include "mtcp_epoll.h" 6 7 /*----------------------------------------------------------------------------*/ 8 struct mtcp_epoll_stat 9 { 10 uint64_t calls; 11 uint64_t waits; 12 uint64_t wakes; 13 14 uint64_t issued; 15 uint64_t registered; 16 uint64_t invalidated; 17 uint64_t handled; 18 }; 19 /*----------------------------------------------------------------------------*/ 20 struct mtcp_epoll_event_int 21 { 22 struct mtcp_epoll_event ev; 23 int sockid; 24 }; 25 /*----------------------------------------------------------------------------*/ 26 enum event_queue_type 27 { 28 USR_EVENT_QUEUE = 0, 29 USR_SHADOW_EVENT_QUEUE = 1, 30 MOS_EVENT_QUEUE = 2 31 }; 32 /*----------------------------------------------------------------------------*/ 33 struct event_queue 34 { 35 struct mtcp_epoll_event_int *events; 36 int start; // starting index 37 int end; // ending index 38 39 int size; // max size 40 int num_events; // number of events 41 }; 42 /*----------------------------------------------------------------------------*/ 43 struct mtcp_epoll 44 { 45 struct event_queue *usr_queue; 46 struct event_queue *usr_shadow_queue; 47 struct event_queue *mtcp_queue; 48 49 uint8_t waiting; 50 struct mtcp_epoll_stat stat; 51 52 pthread_cond_t epoll_cond; 53 pthread_mutex_t epoll_lock; 54 }; 55 /*----------------------------------------------------------------------------*/ 56 57 int 58 CloseEpollSocket(mctx_t mctx, int epid); 59 60 struct event_queue * 61 CreateEventQueue(int size); 62 63 void 64 DestroyEventQueue(struct event_queue *eq); 65 66 #endif /* __EVENTPOLL_H_ */ 67