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

Comparing libev/ev.c (file contents):
Revision 1.352 by root, Thu Oct 21 02:33:08 2010 UTC vs.
Revision 1.353 by root, Thu Oct 21 12:32:47 2010 UTC

717# define EV_RELEASE_CB (void)0 717# define EV_RELEASE_CB (void)0
718# define EV_ACQUIRE_CB (void)0 718# define EV_ACQUIRE_CB (void)0
719# define EV_INVOKE_PENDING ev_invoke_pending (EV_A) 719# define EV_INVOKE_PENDING ev_invoke_pending (EV_A)
720#endif 720#endif
721 721
722#define EVUNLOOP_RECURSE 0x80 722#define EVBREAK_RECURSE 0x80
723 723
724/*****************************************************************************/ 724/*****************************************************************************/
725 725
726#ifndef EV_HAVE_EV_TIME 726#ifndef EV_HAVE_EV_TIME
727ev_tstamp 727ev_tstamp
2292 mn_now = ev_rt_now; 2292 mn_now = ev_rt_now;
2293 } 2293 }
2294} 2294}
2295 2295
2296void 2296void
2297ev_loop (EV_P_ int flags) 2297ev_run (EV_P_ int flags)
2298{ 2298{
2299#if EV_FEATURE_API 2299#if EV_FEATURE_API
2300 ++loop_depth; 2300 ++loop_depth;
2301#endif 2301#endif
2302 2302
2303 assert (("libev: ev_loop recursion during release detected", loop_done != EVUNLOOP_RECURSE)); 2303 assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE));
2304 2304
2305 loop_done = EVUNLOOP_CANCEL; 2305 loop_done = EVBREAK_CANCEL;
2306 2306
2307 EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */ 2307 EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */
2308 2308
2309 do 2309 do
2310 { 2310 {
2353 /* calculate blocking time */ 2353 /* calculate blocking time */
2354 { 2354 {
2355 ev_tstamp waittime = 0.; 2355 ev_tstamp waittime = 0.;
2356 ev_tstamp sleeptime = 0.; 2356 ev_tstamp sleeptime = 0.;
2357 2357
2358 /* remember old timestamp for io_blocktime calculation */
2359 ev_tstamp prev_mn_now = mn_now;
2360
2361 /* update time to cancel out callback processing overhead */
2362 time_update (EV_A_ 1e100);
2363
2358 if (expect_true (!(flags & EVLOOP_NONBLOCK || idleall || !activecnt))) 2364 if (expect_true (!(flags & EVRUN_NOWAIT || idleall || !activecnt)))
2359 { 2365 {
2360 /* remember old timestamp for io_blocktime calculation */
2361 ev_tstamp prev_mn_now = mn_now;
2362
2363 /* update time to cancel out callback processing overhead */
2364 time_update (EV_A_ 1e100);
2365
2366 waittime = MAX_BLOCKTIME; 2366 waittime = MAX_BLOCKTIME;
2367 2367
2368 if (timercnt) 2368 if (timercnt)
2369 { 2369 {
2370 ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now + backend_fudge; 2370 ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now + backend_fudge;
2400 } 2400 }
2401 2401
2402#if EV_FEATURE_API 2402#if EV_FEATURE_API
2403 ++loop_count; 2403 ++loop_count;
2404#endif 2404#endif
2405 assert ((loop_done = EVUNLOOP_RECURSE, 1)); /* assert for side effect */ 2405 assert ((loop_done = EVBREAK_RECURSE, 1)); /* assert for side effect */
2406 backend_poll (EV_A_ waittime); 2406 backend_poll (EV_A_ waittime);
2407 assert ((loop_done = EVUNLOOP_CANCEL, 1)); /* assert for side effect */ 2407 assert ((loop_done = EVBREAK_CANCEL, 1)); /* assert for side effect */
2408 2408
2409 /* update ev_rt_now, do magic */ 2409 /* update ev_rt_now, do magic */
2410 time_update (EV_A_ waittime + sleeptime); 2410 time_update (EV_A_ waittime + sleeptime);
2411 } 2411 }
2412 2412
2430 EV_INVOKE_PENDING; 2430 EV_INVOKE_PENDING;
2431 } 2431 }
2432 while (expect_true ( 2432 while (expect_true (
2433 activecnt 2433 activecnt
2434 && !loop_done 2434 && !loop_done
2435 && !(flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK)) 2435 && !(flags & (EVRUN_ONCE | EVRUN_NOWAIT))
2436 )); 2436 ));
2437 2437
2438 if (loop_done == EVUNLOOP_ONE) 2438 if (loop_done == EVBREAK_ONE)
2439 loop_done = EVUNLOOP_CANCEL; 2439 loop_done = EVBREAK_CANCEL;
2440 2440
2441#if EV_FEATURE_API 2441#if EV_FEATURE_API
2442 --loop_depth; 2442 --loop_depth;
2443#endif 2443#endif
2444} 2444}
2445 2445
2446void 2446void
2447ev_unloop (EV_P_ int how) 2447ev_break (EV_P_ int how)
2448{ 2448{
2449 loop_done = how; 2449 loop_done = how;
2450} 2450}
2451 2451
2452void 2452void
3427 3427
3428#if EV_EMBED_ENABLE 3428#if EV_EMBED_ENABLE
3429void noinline 3429void noinline
3430ev_embed_sweep (EV_P_ ev_embed *w) 3430ev_embed_sweep (EV_P_ ev_embed *w)
3431{ 3431{
3432 ev_loop (w->other, EVLOOP_NONBLOCK); 3432 ev_run (w->other, EVRUN_NOWAIT);
3433} 3433}
3434 3434
3435static void 3435static void
3436embed_io_cb (EV_P_ ev_io *io, int revents) 3436embed_io_cb (EV_P_ ev_io *io, int revents)
3437{ 3437{
3438 ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io)); 3438 ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io));
3439 3439
3440 if (ev_cb (w)) 3440 if (ev_cb (w))
3441 ev_feed_event (EV_A_ (W)w, EV_EMBED); 3441 ev_feed_event (EV_A_ (W)w, EV_EMBED);
3442 else 3442 else
3443 ev_loop (w->other, EVLOOP_NONBLOCK); 3443 ev_run (w->other, EVRUN_NOWAIT);
3444} 3444}
3445 3445
3446static void 3446static void
3447embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents) 3447embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents)
3448{ 3448{
3452 EV_P = w->other; 3452 EV_P = w->other;
3453 3453
3454 while (fdchangecnt) 3454 while (fdchangecnt)
3455 { 3455 {
3456 fd_reify (EV_A); 3456 fd_reify (EV_A);
3457 ev_loop (EV_A_ EVLOOP_NONBLOCK); 3457 ev_run (EV_A_ EVRUN_NOWAIT);
3458 } 3458 }
3459 } 3459 }
3460} 3460}
3461 3461
3462static void 3462static void
3468 3468
3469 { 3469 {
3470 EV_P = w->other; 3470 EV_P = w->other;
3471 3471
3472 ev_loop_fork (EV_A); 3472 ev_loop_fork (EV_A);
3473 ev_loop (EV_A_ EVLOOP_NONBLOCK); 3473 ev_run (EV_A_ EVRUN_NOWAIT);
3474 } 3474 }
3475 3475
3476 ev_embed_start (EV_A_ w); 3476 ev_embed_start (EV_A_ w);
3477} 3477}
3478 3478

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines