ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.186 by root, Sat Dec 15 23:14:38 2007 UTC vs.
Revision 1.192 by root, Fri Dec 21 07:55:29 2007 UTC

925} 925}
926 926
927unsigned int 927unsigned int
928ev_embeddable_backends (void) 928ev_embeddable_backends (void)
929{ 929{
930 /* epoll embeddability broken on all linux versions up to at least 2.6.23 */
930 return EVBACKEND_EPOLL 931 return EVBACKEND_KQUEUE
931 | EVBACKEND_KQUEUE
932 | EVBACKEND_PORT; 932 | EVBACKEND_PORT;
933} 933}
934 934
935unsigned int 935unsigned int
936ev_backend (EV_P) 936ev_backend (EV_P)
1046 array_free (fdchange, EMPTY); 1046 array_free (fdchange, EMPTY);
1047 array_free (timer, EMPTY); 1047 array_free (timer, EMPTY);
1048#if EV_PERIODIC_ENABLE 1048#if EV_PERIODIC_ENABLE
1049 array_free (periodic, EMPTY); 1049 array_free (periodic, EMPTY);
1050#endif 1050#endif
1051#if EV_FORK_ENABLE
1052 array_free (fork, EMPTY);
1053#endif
1051 array_free (prepare, EMPTY); 1054 array_free (prepare, EMPTY);
1052 array_free (check, EMPTY); 1055 array_free (check, EMPTY);
1053 array_free (fork, EMPTY);
1054 1056
1055 backend = 0; 1057 backend = 0;
1056} 1058}
1057 1059
1058void inline_size infy_fork (EV_P); 1060void inline_size infy_fork (EV_P);
2180 2182
2181#if EV_EMBED_ENABLE 2183#if EV_EMBED_ENABLE
2182void noinline 2184void noinline
2183ev_embed_sweep (EV_P_ ev_embed *w) 2185ev_embed_sweep (EV_P_ ev_embed *w)
2184{ 2186{
2185 ev_loop (w->loop, EVLOOP_NONBLOCK); 2187 ev_loop (w->other, EVLOOP_NONBLOCK);
2186} 2188}
2187 2189
2188static void 2190static void
2189embed_cb (EV_P_ ev_io *io, int revents) 2191embed_io_cb (EV_P_ ev_io *io, int revents)
2190{ 2192{
2191 ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io)); 2193 ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io));
2192 2194
2193 if (ev_cb (w)) 2195 if (ev_cb (w))
2194 ev_feed_event (EV_A_ (W)w, EV_EMBED); 2196 ev_feed_event (EV_A_ (W)w, EV_EMBED);
2195 else 2197 else
2196 ev_embed_sweep (loop, w); 2198 ev_embed_sweep (loop, w);
2197} 2199}
2198 2200
2201static void
2202embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents)
2203{
2204 ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare));
2205
2206 fd_reify (w->other);
2207}
2208
2199void 2209void
2200ev_embed_start (EV_P_ ev_embed *w) 2210ev_embed_start (EV_P_ ev_embed *w)
2201{ 2211{
2202 if (expect_false (ev_is_active (w))) 2212 if (expect_false (ev_is_active (w)))
2203 return; 2213 return;
2204 2214
2205 { 2215 {
2206 struct ev_loop *loop = w->loop; 2216 struct ev_loop *loop = w->other;
2207 assert (("loop to be embedded is not embeddable", backend & ev_embeddable_backends ())); 2217 assert (("loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
2208 ev_io_init (&w->io, embed_cb, backend_fd, EV_READ); 2218 ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ);
2209 } 2219 }
2210 2220
2211 ev_set_priority (&w->io, ev_priority (w)); 2221 ev_set_priority (&w->io, ev_priority (w));
2212 ev_io_start (EV_A_ &w->io); 2222 ev_io_start (EV_A_ &w->io);
2213 2223
2224 ev_prepare_init (&w->prepare, embed_prepare_cb);
2225 ev_set_priority (&w->prepare, EV_MINPRI);
2226 ev_prepare_start (EV_A_ &w->prepare);
2227
2214 ev_start (EV_A_ (W)w, 1); 2228 ev_start (EV_A_ (W)w, 1);
2215} 2229}
2216 2230
2217void 2231void
2218ev_embed_stop (EV_P_ ev_embed *w) 2232ev_embed_stop (EV_P_ ev_embed *w)
2220 clear_pending (EV_A_ (W)w); 2234 clear_pending (EV_A_ (W)w);
2221 if (expect_false (!ev_is_active (w))) 2235 if (expect_false (!ev_is_active (w)))
2222 return; 2236 return;
2223 2237
2224 ev_io_stop (EV_A_ &w->io); 2238 ev_io_stop (EV_A_ &w->io);
2239 ev_prepare_stop (EV_A_ &w->prepare);
2225 2240
2226 ev_stop (EV_A_ (W)w); 2241 ev_stop (EV_A_ (W)w);
2227} 2242}
2228#endif 2243#endif
2229 2244
2318 ev_timer_set (&once->to, timeout, 0.); 2333 ev_timer_set (&once->to, timeout, 0.);
2319 ev_timer_start (EV_A_ &once->to); 2334 ev_timer_start (EV_A_ &once->to);
2320 } 2335 }
2321} 2336}
2322 2337
2338#if EV_MULTIPLICITY
2339 #include "ev_wrap.h"
2340#endif
2341
2323#ifdef __cplusplus 2342#ifdef __cplusplus
2324} 2343}
2325#endif 2344#endif
2326 2345

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines