52 Session *sn; |
54 Session *sn; |
53 Request *rq; |
55 Request *rq; |
54 int ret; |
56 int ret; |
55 } EVReturn; |
57 } EVReturn; |
56 |
58 |
|
59 typedef struct EVWatchList EVWatchList; |
|
60 typedef void(*evwatchlist_destroyfunc)(EventHandler *h, EVWatchList *item, void *data); |
|
61 |
|
62 struct EVWatchList { |
|
63 time_t created; |
|
64 time_t expire; |
|
65 evwatchlist_destroyfunc destroy; |
|
66 void *destroydata; |
|
67 EVWatchList *prev; |
|
68 EVWatchList *next; |
|
69 }; |
|
70 |
|
71 |
|
72 typedef struct EventHandler { |
|
73 /* |
|
74 * return call list |
|
75 */ |
|
76 EVReturn fnreturn[EV_MAX_EVENTS]; |
|
77 /* |
|
78 * number of fnreturn entries |
|
79 */ |
|
80 int numret; |
|
81 |
|
82 EVWatchList *watchlist_begin; |
|
83 EVWatchList *watchlist_end; |
|
84 } EventHandler; |
|
85 |
|
86 |
|
87 |
57 int create_event_handler(EventHandlerConfig *cfg); |
88 int create_event_handler(EventHandlerConfig *cfg); |
58 |
89 |
59 int check_event_handler_cfg(); |
90 int check_event_handler_cfg(); |
60 |
91 |
61 EVHandler* get_default_event_handler(); |
92 EVHandler* get_default_event_handler(); |
62 |
93 |
63 EVHandler* get_event_handler(const char *name); |
94 EVHandler* get_event_handler(const char *name); |
64 |
95 |
65 EventHandler* ev_instance(EVHandler *ev); |
96 EventHandler* ev_instance(EVHandler *ev); |
|
97 |
|
98 void watchlist_add(EVWatchList **begin, EVWatchList **end, EVWatchList *elm); |
|
99 void watchlist_remove(EVWatchList **begin, EVWatchList **end, EVWatchList *elm); |
|
100 |
|
101 void watchlist_check(EventHandler *h, time_t t); |
66 |
102 |
67 /* implementation in event_$platform */ |
103 /* implementation in event_$platform */ |
68 EVHandler* evhandler_create(EventHandlerConfig *cfg); |
104 EVHandler* evhandler_create(EventHandlerConfig *cfg); |
69 |
105 |
70 int ev_pollin(EventHandler *h, int fd, Event *event); |
106 int ev_pollin(EventHandler *h, int fd, Event *event); |
75 int ev_aioread(int fd, aiocb_s *cb); |
111 int ev_aioread(int fd, aiocb_s *cb); |
76 int ev_aiowrite(int fd, aiocb_s *cb); |
112 int ev_aiowrite(int fd, aiocb_s *cb); |
77 |
113 |
78 void ev_saf_return(EventHandler *h, Session *sn, Request *rq, int ret); |
114 void ev_saf_return(EventHandler *h, Session *sn, Request *rq, int ret); |
79 |
115 |
|
116 void ev_watchlist_add(EventHandler *h, EVWatchList *elm); |
|
117 void ev_watchlist_remove(EventHandler *h, EVWatchList *elm); |
|
118 |
80 |
119 |
81 #ifdef __cplusplus |
120 #ifdef __cplusplus |
82 } |
121 } |
83 #endif |
122 #endif |
84 |
123 |