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

Comparing libev/ev.c (file contents):
Revision 1.185 by root, Fri Dec 14 18:22:30 2007 UTC vs.
Revision 1.189 by root, Thu Dec 20 10:12:22 2007 UTC

1038#if EV_IDLE_ENABLE 1038#if EV_IDLE_ENABLE
1039 array_free (idle, [i]); 1039 array_free (idle, [i]);
1040#endif 1040#endif
1041 } 1041 }
1042 1042
1043 ev_free (anfds); anfdmax = 0;
1044
1043 /* have to use the microsoft-never-gets-it-right macro */ 1045 /* have to use the microsoft-never-gets-it-right macro */
1044 array_free (fdchange, EMPTY); 1046 array_free (fdchange, EMPTY);
1045 array_free (timer, EMPTY); 1047 array_free (timer, EMPTY);
1046#if EV_PERIODIC_ENABLE 1048#if EV_PERIODIC_ENABLE
1047 array_free (periodic, EMPTY); 1049 array_free (periodic, EMPTY);
1050#endif
1051#if EV_FORK_ENABLE
1052 array_free (fork, EMPTY);
1048#endif 1053#endif
1049 array_free (prepare, EMPTY); 1054 array_free (prepare, EMPTY);
1050 array_free (check, EMPTY); 1055 array_free (check, EMPTY);
1051 1056
1052 backend = 0; 1057 backend = 0;
2177 2182
2178#if EV_EMBED_ENABLE 2183#if EV_EMBED_ENABLE
2179void noinline 2184void noinline
2180ev_embed_sweep (EV_P_ ev_embed *w) 2185ev_embed_sweep (EV_P_ ev_embed *w)
2181{ 2186{
2182 ev_loop (w->loop, EVLOOP_NONBLOCK); 2187 ev_loop (w->other, EVLOOP_NONBLOCK);
2183} 2188}
2184 2189
2185static void 2190static void
2186embed_cb (EV_P_ ev_io *io, int revents) 2191embed_io_cb (EV_P_ ev_io *io, int revents)
2187{ 2192{
2188 ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io)); 2193 ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io));
2189 2194
2190 if (ev_cb (w)) 2195 if (ev_cb (w))
2191 ev_feed_event (EV_A_ (W)w, EV_EMBED); 2196 ev_feed_event (EV_A_ (W)w, EV_EMBED);
2192 else 2197 else
2193 ev_embed_sweep (loop, w); 2198 ev_embed_sweep (loop, w);
2194} 2199}
2195 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
2196void 2209void
2197ev_embed_start (EV_P_ ev_embed *w) 2210ev_embed_start (EV_P_ ev_embed *w)
2198{ 2211{
2199 if (expect_false (ev_is_active (w))) 2212 if (expect_false (ev_is_active (w)))
2200 return; 2213 return;
2201 2214
2202 { 2215 {
2203 struct ev_loop *loop = w->loop; 2216 struct ev_loop *loop = w->other;
2204 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 ()));
2205 ev_io_init (&w->io, embed_cb, backend_fd, EV_READ); 2218 ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ);
2206 } 2219 }
2207 2220
2208 ev_set_priority (&w->io, ev_priority (w)); 2221 ev_set_priority (&w->io, ev_priority (w));
2209 ev_io_start (EV_A_ &w->io); 2222 ev_io_start (EV_A_ &w->io);
2210 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
2211 ev_start (EV_A_ (W)w, 1); 2228 ev_start (EV_A_ (W)w, 1);
2212} 2229}
2213 2230
2214void 2231void
2215ev_embed_stop (EV_P_ ev_embed *w) 2232ev_embed_stop (EV_P_ ev_embed *w)
2217 clear_pending (EV_A_ (W)w); 2234 clear_pending (EV_A_ (W)w);
2218 if (expect_false (!ev_is_active (w))) 2235 if (expect_false (!ev_is_active (w)))
2219 return; 2236 return;
2220 2237
2221 ev_io_stop (EV_A_ &w->io); 2238 ev_io_stop (EV_A_ &w->io);
2239 ev_prepare_stop (EV_A_ &w->prepare);
2222 2240
2223 ev_stop (EV_A_ (W)w); 2241 ev_stop (EV_A_ (W)w);
2224} 2242}
2225#endif 2243#endif
2226 2244
2315 ev_timer_set (&once->to, timeout, 0.); 2333 ev_timer_set (&once->to, timeout, 0.);
2316 ev_timer_start (EV_A_ &once->to); 2334 ev_timer_start (EV_A_ &once->to);
2317 } 2335 }
2318} 2336}
2319 2337
2338#if EV_MULTIPLICITY
2339 #include "ev_wrap.h"
2340#endif
2341
2320#ifdef __cplusplus 2342#ifdef __cplusplus
2321} 2343}
2322#endif 2344#endif
2323 2345

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines