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

Comparing libev/ev.c (file contents):
Revision 1.158 by root, Thu Nov 29 17:28:13 2007 UTC vs.
Revision 1.162 by root, Mon Dec 3 13:41:24 2007 UTC

886ev_backend (EV_P) 886ev_backend (EV_P)
887{ 887{
888 return backend; 888 return backend;
889} 889}
890 890
891unsigned int
892ev_loop_count (EV_P)
893{
894 return loop_count;
895}
896
891static void noinline 897static void noinline
892loop_init (EV_P_ unsigned int flags) 898loop_init (EV_P_ unsigned int flags)
893{ 899{
894 if (!backend) 900 if (!backend)
895 { 901 {
1342 ? EVUNLOOP_ONE 1348 ? EVUNLOOP_ONE
1343 : EVUNLOOP_CANCEL; 1349 : EVUNLOOP_CANCEL;
1344 1350
1345 call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */ 1351 call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */
1346 1352
1347 while (activecnt) 1353 do
1348 { 1354 {
1349#ifndef _WIN32 1355#ifndef _WIN32
1350 if (expect_false (curpid)) /* penalise the forking check even more */ 1356 if (expect_false (curpid)) /* penalise the forking check even more */
1351 if (expect_false (getpid () != curpid)) 1357 if (expect_false (getpid () != curpid))
1352 { 1358 {
1370 { 1376 {
1371 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 1377 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
1372 call_pending (EV_A); 1378 call_pending (EV_A);
1373 } 1379 }
1374 1380
1381 if (expect_false (!activecnt))
1382 break;
1383
1375 /* we might have forked, so reify kernel state if necessary */ 1384 /* we might have forked, so reify kernel state if necessary */
1376 if (expect_false (postfork)) 1385 if (expect_false (postfork))
1377 loop_fork (EV_A); 1386 loop_fork (EV_A);
1378 1387
1379 /* update fd-related kernel structures */ 1388 /* update fd-related kernel structures */
1381 1390
1382 /* calculate blocking time */ 1391 /* calculate blocking time */
1383 { 1392 {
1384 ev_tstamp block; 1393 ev_tstamp block;
1385 1394
1386 if (flags & EVLOOP_NONBLOCK || idlecnt) 1395 if (expect_false (flags & EVLOOP_NONBLOCK || idlecnt || !activecnt))
1387 block = 0.; /* do not block at all */ 1396 block = 0.; /* do not block at all */
1388 else 1397 else
1389 { 1398 {
1390 /* update time to cancel out callback processing overhead */ 1399 /* update time to cancel out callback processing overhead */
1391#if EV_USE_MONOTONIC 1400#if EV_USE_MONOTONIC
1415#endif 1424#endif
1416 1425
1417 if (expect_false (block < 0.)) block = 0.; 1426 if (expect_false (block < 0.)) block = 0.;
1418 } 1427 }
1419 1428
1429 ++loop_count;
1420 backend_poll (EV_A_ block); 1430 backend_poll (EV_A_ block);
1421 } 1431 }
1422 1432
1423 /* update ev_rt_now, do magic */ 1433 /* update ev_rt_now, do magic */
1424 time_update (EV_A); 1434 time_update (EV_A);
1437 if (expect_false (checkcnt)) 1447 if (expect_false (checkcnt))
1438 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 1448 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
1439 1449
1440 call_pending (EV_A); 1450 call_pending (EV_A);
1441 1451
1442 if (expect_false (loop_done))
1443 break;
1444 } 1452 }
1453 while (expect_true (activecnt && !loop_done));
1445 1454
1446 if (loop_done == EVUNLOOP_ONE) 1455 if (loop_done == EVUNLOOP_ONE)
1447 loop_done = EVUNLOOP_CANCEL; 1456 loop_done = EVUNLOOP_CANCEL;
1448} 1457}
1449 1458

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines