… | |
… | |
88 | int event_dispatch (void) |
88 | int event_dispatch (void) |
89 | { |
89 | { |
90 | return event_base_dispatch (x_cur); |
90 | return event_base_dispatch (x_cur); |
91 | } |
91 | } |
92 | |
92 | |
|
|
93 | #ifdef EV_STANDALONE |
93 | void event_set_log_callback (event_log_cb cb) |
94 | void event_set_log_callback (event_log_cb cb) |
94 | { |
95 | { |
95 | /* nop */ |
96 | /* nop */ |
96 | } |
97 | } |
|
|
98 | #endif |
97 | |
99 | |
98 | int event_loop (int flags) |
100 | int event_loop (int flags) |
99 | { |
101 | { |
100 | return event_base_loop (x_cur, flags); |
102 | return event_base_loop (x_cur, flags); |
101 | } |
103 | } |
102 | |
104 | |
103 | int event_loopexit (struct timeval *tv) |
105 | int event_loopexit (struct timeval *tv) |
104 | { |
106 | { |
105 | event_base_loopexit (x_cur, tv); |
107 | return event_base_loopexit (x_cur, tv); |
106 | } |
108 | } |
107 | |
109 | |
108 | static void |
110 | static void |
109 | x_cb (struct event *ev, int revents) |
111 | x_cb (struct event *ev, int revents) |
110 | { |
112 | { |
… | |
… | |
172 | ev->ev_res = 0; |
174 | ev->ev_res = 0; |
173 | } |
175 | } |
174 | |
176 | |
175 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) |
177 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) |
176 | { |
178 | { |
177 | event_base_once (x_cur, fd, events, cb, arg, tv); |
179 | return event_base_once (x_cur, fd, events, cb, arg, tv); |
178 | } |
180 | } |
179 | |
181 | |
180 | int event_add (struct event *ev, struct timeval *tv) |
182 | int event_add (struct event *ev, struct timeval *tv) |
181 | { |
183 | { |
182 | /* disable all watchers */ |
184 | /* disable all watchers */ |
… | |
… | |
235 | return 0; |
237 | return 0; |
236 | } |
238 | } |
237 | |
239 | |
238 | int event_pending (struct event *ev, short events, struct timeval *tv) |
240 | int event_pending (struct event *ev, short events, struct timeval *tv) |
239 | { |
241 | { |
240 | short revents; |
242 | short revents = 0; |
241 | |
243 | |
242 | if (ev->ev_events & EV_SIGNAL) |
244 | if (ev->ev_events & EV_SIGNAL) |
243 | { |
245 | { |
244 | /* sig */ |
246 | /* sig */ |
245 | if (ev->iosig.sig.pending) |
247 | if (ev->iosig.sig.pending) |
… | |
… | |
307 | int event_base_loopexit (struct event_base *base, struct timeval *tv) |
309 | int event_base_loopexit (struct event_base *base, struct timeval *tv) |
308 | { |
310 | { |
309 | ev_tstamp after = tv_get (tv); |
311 | ev_tstamp after = tv_get (tv); |
310 | |
312 | |
311 | ev_once (-1, 0, after >= 0. ? after : 0., x_loopexit_cb, (void *)base); |
313 | ev_once (-1, 0, after >= 0. ? after : 0., x_loopexit_cb, (void *)base); |
|
|
314 | |
|
|
315 | return -1; |
312 | } |
316 | } |
313 | |
317 | |
314 | struct x_once |
318 | struct x_once |
315 | { |
319 | { |
316 | int fd; |
320 | int fd; |