… | |
… | |
280 | |
280 | |
281 | typedef ev_watcher *W; |
281 | typedef ev_watcher *W; |
282 | typedef ev_watcher_list *WL; |
282 | typedef ev_watcher_list *WL; |
283 | typedef ev_watcher_time *WT; |
283 | typedef ev_watcher_time *WT; |
284 | |
284 | |
|
|
285 | #if EV_USE_MONOTONIC |
285 | /* sig_atomic_t is used to avoid per-thread variables or locking but still */ |
286 | /* sig_atomic_t is used to avoid per-thread variables or locking but still */ |
286 | /* giving it a reasonably high chance of working on typical architetcures */ |
287 | /* giving it a reasonably high chance of working on typical architetcures */ |
287 | static sig_atomic_t have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
288 | static sig_atomic_t have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
|
|
289 | #endif |
288 | |
290 | |
289 | #ifdef _WIN32 |
291 | #ifdef _WIN32 |
290 | # include "ev_win32.c" |
292 | # include "ev_win32.c" |
291 | #endif |
293 | #endif |
292 | |
294 | |
… | |
… | |
972 | } |
974 | } |
973 | |
975 | |
974 | unsigned int |
976 | unsigned int |
975 | ev_embeddable_backends (void) |
977 | ev_embeddable_backends (void) |
976 | { |
978 | { |
|
|
979 | int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT; |
|
|
980 | |
977 | /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ |
981 | /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ |
978 | return EVBACKEND_KQUEUE |
982 | /* please fix it and tell me how to detect the fix */ |
979 | | EVBACKEND_PORT; |
983 | flags &= ~EVBACKEND_EPOLL; |
|
|
984 | |
|
|
985 | return flags; |
980 | } |
986 | } |
981 | |
987 | |
982 | unsigned int |
988 | unsigned int |
983 | ev_backend (EV_P) |
989 | ev_backend (EV_P) |
984 | { |
990 | { |
… | |
… | |
2266 | ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io)); |
2272 | ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io)); |
2267 | |
2273 | |
2268 | if (ev_cb (w)) |
2274 | if (ev_cb (w)) |
2269 | ev_feed_event (EV_A_ (W)w, EV_EMBED); |
2275 | ev_feed_event (EV_A_ (W)w, EV_EMBED); |
2270 | else |
2276 | else |
2271 | ev_embed_sweep (loop, w); |
2277 | ev_loop (w->other, EVLOOP_NONBLOCK); |
2272 | } |
2278 | } |
2273 | |
2279 | |
2274 | static void |
2280 | static void |
2275 | embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents) |
2281 | embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents) |
2276 | { |
2282 | { |
2277 | ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare)); |
2283 | ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare)); |
2278 | |
2284 | |
2279 | fd_reify (w->other); |
2285 | { |
|
|
2286 | struct ev_loop *loop = w->other; |
|
|
2287 | |
|
|
2288 | while (fdchangecnt) |
|
|
2289 | { |
|
|
2290 | fd_reify (EV_A); |
|
|
2291 | ev_loop (EV_A_ EVLOOP_NONBLOCK); |
|
|
2292 | } |
|
|
2293 | } |
2280 | } |
2294 | } |
|
|
2295 | |
|
|
2296 | #if 0 |
|
|
2297 | static void |
|
|
2298 | embed_idle_cb (EV_P_ ev_idle *idle, int revents) |
|
|
2299 | { |
|
|
2300 | ev_idle_stop (EV_A_ idle); |
|
|
2301 | } |
|
|
2302 | #endif |
2281 | |
2303 | |
2282 | void |
2304 | void |
2283 | ev_embed_start (EV_P_ ev_embed *w) |
2305 | ev_embed_start (EV_P_ ev_embed *w) |
2284 | { |
2306 | { |
2285 | if (expect_false (ev_is_active (w))) |
2307 | if (expect_false (ev_is_active (w))) |
… | |
… | |
2296 | |
2318 | |
2297 | ev_prepare_init (&w->prepare, embed_prepare_cb); |
2319 | ev_prepare_init (&w->prepare, embed_prepare_cb); |
2298 | ev_set_priority (&w->prepare, EV_MINPRI); |
2320 | ev_set_priority (&w->prepare, EV_MINPRI); |
2299 | ev_prepare_start (EV_A_ &w->prepare); |
2321 | ev_prepare_start (EV_A_ &w->prepare); |
2300 | |
2322 | |
|
|
2323 | /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ |
|
|
2324 | |
2301 | ev_start (EV_A_ (W)w, 1); |
2325 | ev_start (EV_A_ (W)w, 1); |
2302 | } |
2326 | } |
2303 | |
2327 | |
2304 | void |
2328 | void |
2305 | ev_embed_stop (EV_P_ ev_embed *w) |
2329 | ev_embed_stop (EV_P_ ev_embed *w) |