… | |
… | |
241 | |
241 | |
242 | #define expect_false(expr) expect ((expr) != 0, 0) |
242 | #define expect_false(expr) expect ((expr) != 0, 0) |
243 | #define expect_true(expr) expect ((expr) != 0, 1) |
243 | #define expect_true(expr) expect ((expr) != 0, 1) |
244 | |
244 | |
245 | #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) |
245 | #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) |
246 | #define ABSPRI(w) ((w)->priority - EV_MINPRI) |
246 | #define ABSPRI(w) (((W)w)->priority - EV_MINPRI) |
247 | |
247 | |
248 | #define EMPTY0 /* required for microsofts broken pseudo-c compiler */ |
248 | #define EMPTY /* required for microsofts broken pseudo-c compiler */ |
249 | #define EMPTY2(a,b) /* used to suppress some warnings */ |
249 | #define EMPTY2(a,b) /* used to suppress some warnings */ |
250 | |
250 | |
251 | typedef ev_watcher *W; |
251 | typedef ev_watcher *W; |
252 | typedef ev_watcher_list *WL; |
252 | typedef ev_watcher_list *WL; |
253 | typedef ev_watcher_time *WT; |
253 | typedef ev_watcher_time *WT; |
… | |
… | |
396 | { |
396 | { |
397 | return ev_rt_now; |
397 | return ev_rt_now; |
398 | } |
398 | } |
399 | #endif |
399 | #endif |
400 | |
400 | |
401 | #define array_roundsize(type,n) (((n) | 4) & ~3) |
401 | int inline_size |
|
|
402 | array_nextsize (int elem, int cur, int cnt) |
|
|
403 | { |
|
|
404 | int ncur = cur + 1; |
|
|
405 | |
|
|
406 | do |
|
|
407 | ncur <<= 1; |
|
|
408 | while (cnt > ncur); |
|
|
409 | |
|
|
410 | /* if size > 4096, round to 4096 - 4 * longs to accomodate malloc overhead */ |
|
|
411 | if (elem * ncur > 4096) |
|
|
412 | { |
|
|
413 | ncur *= elem; |
|
|
414 | ncur = (ncur + elem + 4095 + sizeof (void *) * 4) & ~4095; |
|
|
415 | ncur = ncur - sizeof (void *) * 4; |
|
|
416 | ncur /= elem; |
|
|
417 | } |
|
|
418 | |
|
|
419 | return ncur; |
|
|
420 | } |
|
|
421 | |
|
|
422 | inline_speed void * |
|
|
423 | array_realloc (int elem, void *base, int *cur, int cnt) |
|
|
424 | { |
|
|
425 | *cur = array_nextsize (elem, *cur, cnt); |
|
|
426 | return ev_realloc (base, elem * *cur); |
|
|
427 | } |
402 | |
428 | |
403 | #define array_needsize(type,base,cur,cnt,init) \ |
429 | #define array_needsize(type,base,cur,cnt,init) \ |
404 | if (expect_false ((cnt) > cur)) \ |
430 | if (expect_false ((cnt) > (cur))) \ |
405 | { \ |
431 | { \ |
406 | int newcnt = cur; \ |
432 | int ocur_ = (cur); \ |
407 | do \ |
433 | (base) = (type *)array_realloc \ |
408 | { \ |
434 | (sizeof (type), (base), &(cur), (cnt)); \ |
409 | newcnt = array_roundsize (type, newcnt << 1); \ |
435 | init ((base) + (ocur_), (cur) - ocur_); \ |
410 | } \ |
|
|
411 | while ((cnt) > newcnt); \ |
|
|
412 | \ |
|
|
413 | base = (type *)ev_realloc (base, sizeof (type) * (newcnt));\ |
|
|
414 | init (base + cur, newcnt - cur); \ |
|
|
415 | cur = newcnt; \ |
|
|
416 | } |
436 | } |
417 | |
437 | |
|
|
438 | #if 0 |
418 | #define array_slim(type,stem) \ |
439 | #define array_slim(type,stem) \ |
419 | if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ |
440 | if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ |
420 | { \ |
441 | { \ |
421 | stem ## max = array_roundsize (stem ## cnt >> 1); \ |
442 | stem ## max = array_roundsize (stem ## cnt >> 1); \ |
422 | base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\ |
443 | base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\ |
423 | fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ |
444 | fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ |
424 | } |
445 | } |
|
|
446 | #endif |
425 | |
447 | |
426 | #define array_free(stem, idx) \ |
448 | #define array_free(stem, idx) \ |
427 | ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; |
449 | ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; |
428 | |
450 | |
429 | /*****************************************************************************/ |
451 | /*****************************************************************************/ |
… | |
… | |
485 | } |
507 | } |
486 | |
508 | |
487 | void |
509 | void |
488 | ev_feed_fd_event (EV_P_ int fd, int revents) |
510 | ev_feed_fd_event (EV_P_ int fd, int revents) |
489 | { |
511 | { |
|
|
512 | if (fd >= 0 && fd < anfdmax) |
490 | fd_event (EV_A_ fd, revents); |
513 | fd_event (EV_A_ fd, revents); |
491 | } |
514 | } |
492 | |
515 | |
493 | void inline_size |
516 | void inline_size |
494 | fd_reify (EV_P) |
517 | fd_reify (EV_P) |
495 | { |
518 | { |
… | |
… | |
764 | ev_child *w; |
787 | ev_child *w; |
765 | |
788 | |
766 | for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) |
789 | for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) |
767 | if (w->pid == pid || !w->pid) |
790 | if (w->pid == pid || !w->pid) |
768 | { |
791 | { |
769 | ev_priority (w) = ev_priority (sw); /* need to do it *now* */ |
792 | ev_set_priority (w, ev_priority (sw)); /* need to do it *now* */ |
770 | w->rpid = pid; |
793 | w->rpid = pid; |
771 | w->rstatus = status; |
794 | w->rstatus = status; |
772 | ev_feed_event (EV_A_ (W)w, EV_CHILD); |
795 | ev_feed_event (EV_A_ (W)w, EV_CHILD); |
773 | } |
796 | } |
774 | } |
797 | } |
775 | |
798 | |
776 | #ifndef WCONTINUED |
799 | #ifndef WCONTINUED |
… | |
… | |
886 | ev_backend (EV_P) |
909 | ev_backend (EV_P) |
887 | { |
910 | { |
888 | return backend; |
911 | return backend; |
889 | } |
912 | } |
890 | |
913 | |
|
|
914 | unsigned int |
|
|
915 | ev_loop_count (EV_P) |
|
|
916 | { |
|
|
917 | return loop_count; |
|
|
918 | } |
|
|
919 | |
891 | static void noinline |
920 | static void noinline |
892 | loop_init (EV_P_ unsigned int flags) |
921 | loop_init (EV_P_ unsigned int flags) |
893 | { |
922 | { |
894 | if (!backend) |
923 | if (!backend) |
895 | { |
924 | { |
… | |
… | |
975 | #if EV_USE_SELECT |
1004 | #if EV_USE_SELECT |
976 | if (backend == EVBACKEND_SELECT) select_destroy (EV_A); |
1005 | if (backend == EVBACKEND_SELECT) select_destroy (EV_A); |
977 | #endif |
1006 | #endif |
978 | |
1007 | |
979 | for (i = NUMPRI; i--; ) |
1008 | for (i = NUMPRI; i--; ) |
|
|
1009 | { |
980 | array_free (pending, [i]); |
1010 | array_free (pending, [i]); |
|
|
1011 | #if EV_IDLE_ENABLE |
|
|
1012 | array_free (idle, [i]); |
|
|
1013 | #endif |
|
|
1014 | } |
981 | |
1015 | |
982 | /* have to use the microsoft-never-gets-it-right macro */ |
1016 | /* have to use the microsoft-never-gets-it-right macro */ |
983 | array_free (fdchange, EMPTY0); |
1017 | array_free (fdchange, EMPTY); |
984 | array_free (timer, EMPTY0); |
1018 | array_free (timer, EMPTY); |
985 | #if EV_PERIODIC_ENABLE |
1019 | #if EV_PERIODIC_ENABLE |
986 | array_free (periodic, EMPTY0); |
1020 | array_free (periodic, EMPTY); |
987 | #endif |
1021 | #endif |
988 | array_free (idle, EMPTY0); |
|
|
989 | array_free (prepare, EMPTY0); |
1022 | array_free (prepare, EMPTY); |
990 | array_free (check, EMPTY0); |
1023 | array_free (check, EMPTY); |
991 | |
1024 | |
992 | backend = 0; |
1025 | backend = 0; |
993 | } |
1026 | } |
994 | |
1027 | |
995 | void inline_size infy_fork (EV_P); |
1028 | void inline_size infy_fork (EV_P); |
… | |
… | |
1131 | postfork = 1; |
1164 | postfork = 1; |
1132 | } |
1165 | } |
1133 | |
1166 | |
1134 | /*****************************************************************************/ |
1167 | /*****************************************************************************/ |
1135 | |
1168 | |
1136 | int inline_size |
1169 | void |
1137 | any_pending (EV_P) |
1170 | ev_invoke (EV_P_ void *w, int revents) |
1138 | { |
1171 | { |
1139 | int pri; |
1172 | EV_CB_INVOKE ((W)w, revents); |
1140 | |
|
|
1141 | for (pri = NUMPRI; pri--; ) |
|
|
1142 | if (pendingcnt [pri]) |
|
|
1143 | return 1; |
|
|
1144 | |
|
|
1145 | return 0; |
|
|
1146 | } |
1173 | } |
1147 | |
1174 | |
1148 | void inline_speed |
1175 | void inline_speed |
1149 | call_pending (EV_P) |
1176 | call_pending (EV_P) |
1150 | { |
1177 | { |
… | |
… | |
1242 | for (i = periodiccnt >> 1; i--; ) |
1269 | for (i = periodiccnt >> 1; i--; ) |
1243 | downheap ((WT *)periodics, periodiccnt, i); |
1270 | downheap ((WT *)periodics, periodiccnt, i); |
1244 | } |
1271 | } |
1245 | #endif |
1272 | #endif |
1246 | |
1273 | |
|
|
1274 | #if EV_IDLE_ENABLE |
|
|
1275 | void inline_size |
|
|
1276 | idle_reify (EV_P) |
|
|
1277 | { |
|
|
1278 | if (expect_false (idleall)) |
|
|
1279 | { |
|
|
1280 | int pri; |
|
|
1281 | |
|
|
1282 | for (pri = NUMPRI; pri--; ) |
|
|
1283 | { |
|
|
1284 | if (pendingcnt [pri]) |
|
|
1285 | break; |
|
|
1286 | |
|
|
1287 | if (idlecnt [pri]) |
|
|
1288 | { |
|
|
1289 | queue_events (EV_A_ (W *)idles [pri], idlecnt [pri], EV_IDLE); |
|
|
1290 | break; |
|
|
1291 | } |
|
|
1292 | } |
|
|
1293 | } |
|
|
1294 | } |
|
|
1295 | #endif |
|
|
1296 | |
1247 | int inline_size |
1297 | int inline_size |
1248 | time_update_monotonic (EV_P) |
1298 | time_update_monotonic (EV_P) |
1249 | { |
1299 | { |
1250 | mn_now = get_clock (); |
1300 | mn_now = get_clock (); |
1251 | |
1301 | |
… | |
… | |
1342 | ? EVUNLOOP_ONE |
1392 | ? EVUNLOOP_ONE |
1343 | : EVUNLOOP_CANCEL; |
1393 | : EVUNLOOP_CANCEL; |
1344 | |
1394 | |
1345 | call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */ |
1395 | call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */ |
1346 | |
1396 | |
1347 | while (activecnt) |
1397 | do |
1348 | { |
1398 | { |
1349 | #ifndef _WIN32 |
1399 | #ifndef _WIN32 |
1350 | if (expect_false (curpid)) /* penalise the forking check even more */ |
1400 | if (expect_false (curpid)) /* penalise the forking check even more */ |
1351 | if (expect_false (getpid () != curpid)) |
1401 | if (expect_false (getpid () != curpid)) |
1352 | { |
1402 | { |
… | |
… | |
1370 | { |
1420 | { |
1371 | queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); |
1421 | queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); |
1372 | call_pending (EV_A); |
1422 | call_pending (EV_A); |
1373 | } |
1423 | } |
1374 | |
1424 | |
|
|
1425 | if (expect_false (!activecnt)) |
|
|
1426 | break; |
|
|
1427 | |
1375 | /* we might have forked, so reify kernel state if necessary */ |
1428 | /* we might have forked, so reify kernel state if necessary */ |
1376 | if (expect_false (postfork)) |
1429 | if (expect_false (postfork)) |
1377 | loop_fork (EV_A); |
1430 | loop_fork (EV_A); |
1378 | |
1431 | |
1379 | /* update fd-related kernel structures */ |
1432 | /* update fd-related kernel structures */ |
… | |
… | |
1381 | |
1434 | |
1382 | /* calculate blocking time */ |
1435 | /* calculate blocking time */ |
1383 | { |
1436 | { |
1384 | ev_tstamp block; |
1437 | ev_tstamp block; |
1385 | |
1438 | |
1386 | if (flags & EVLOOP_NONBLOCK || idlecnt) |
1439 | if (expect_false (flags & EVLOOP_NONBLOCK || idleall || !activecnt)) |
1387 | block = 0.; /* do not block at all */ |
1440 | block = 0.; /* do not block at all */ |
1388 | else |
1441 | else |
1389 | { |
1442 | { |
1390 | /* update time to cancel out callback processing overhead */ |
1443 | /* update time to cancel out callback processing overhead */ |
1391 | #if EV_USE_MONOTONIC |
1444 | #if EV_USE_MONOTONIC |
… | |
… | |
1415 | #endif |
1468 | #endif |
1416 | |
1469 | |
1417 | if (expect_false (block < 0.)) block = 0.; |
1470 | if (expect_false (block < 0.)) block = 0.; |
1418 | } |
1471 | } |
1419 | |
1472 | |
|
|
1473 | ++loop_count; |
1420 | backend_poll (EV_A_ block); |
1474 | backend_poll (EV_A_ block); |
1421 | } |
1475 | } |
1422 | |
1476 | |
1423 | /* update ev_rt_now, do magic */ |
1477 | /* update ev_rt_now, do magic */ |
1424 | time_update (EV_A); |
1478 | time_update (EV_A); |
… | |
… | |
1427 | timers_reify (EV_A); /* relative timers called last */ |
1481 | timers_reify (EV_A); /* relative timers called last */ |
1428 | #if EV_PERIODIC_ENABLE |
1482 | #if EV_PERIODIC_ENABLE |
1429 | periodics_reify (EV_A); /* absolute timers called first */ |
1483 | periodics_reify (EV_A); /* absolute timers called first */ |
1430 | #endif |
1484 | #endif |
1431 | |
1485 | |
|
|
1486 | #if EV_IDLE_ENABLE |
1432 | /* queue idle watchers unless other events are pending */ |
1487 | /* queue idle watchers unless other events are pending */ |
1433 | if (idlecnt && !any_pending (EV_A)) |
1488 | idle_reify (EV_A); |
1434 | queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE); |
1489 | #endif |
1435 | |
1490 | |
1436 | /* queue check watchers, to be executed first */ |
1491 | /* queue check watchers, to be executed first */ |
1437 | if (expect_false (checkcnt)) |
1492 | if (expect_false (checkcnt)) |
1438 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
1493 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
1439 | |
1494 | |
1440 | call_pending (EV_A); |
1495 | call_pending (EV_A); |
1441 | |
1496 | |
1442 | if (expect_false (loop_done)) |
|
|
1443 | break; |
|
|
1444 | } |
1497 | } |
|
|
1498 | while (expect_true (activecnt && !loop_done)); |
1445 | |
1499 | |
1446 | if (loop_done == EVUNLOOP_ONE) |
1500 | if (loop_done == EVUNLOOP_ONE) |
1447 | loop_done = EVUNLOOP_CANCEL; |
1501 | loop_done = EVUNLOOP_CANCEL; |
1448 | } |
1502 | } |
1449 | |
1503 | |
… | |
… | |
1476 | head = &(*head)->next; |
1530 | head = &(*head)->next; |
1477 | } |
1531 | } |
1478 | } |
1532 | } |
1479 | |
1533 | |
1480 | void inline_speed |
1534 | void inline_speed |
1481 | ev_clear_pending (EV_P_ W w) |
1535 | clear_pending (EV_P_ W w) |
1482 | { |
1536 | { |
1483 | if (w->pending) |
1537 | if (w->pending) |
1484 | { |
1538 | { |
1485 | pendings [ABSPRI (w)][w->pending - 1].w = 0; |
1539 | pendings [ABSPRI (w)][w->pending - 1].w = 0; |
1486 | w->pending = 0; |
1540 | w->pending = 0; |
1487 | } |
1541 | } |
1488 | } |
1542 | } |
1489 | |
1543 | |
|
|
1544 | int |
|
|
1545 | ev_clear_pending (EV_P_ void *w) |
|
|
1546 | { |
|
|
1547 | W w_ = (W)w; |
|
|
1548 | int pending = w_->pending; |
|
|
1549 | |
|
|
1550 | if (!pending) |
|
|
1551 | return 0; |
|
|
1552 | |
|
|
1553 | w_->pending = 0; |
|
|
1554 | ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1; |
|
|
1555 | p->w = 0; |
|
|
1556 | |
|
|
1557 | return p->events; |
|
|
1558 | } |
|
|
1559 | |
|
|
1560 | void inline_size |
|
|
1561 | pri_adjust (EV_P_ W w) |
|
|
1562 | { |
|
|
1563 | int pri = w->priority; |
|
|
1564 | pri = pri < EV_MINPRI ? EV_MINPRI : pri; |
|
|
1565 | pri = pri > EV_MAXPRI ? EV_MAXPRI : pri; |
|
|
1566 | w->priority = pri; |
|
|
1567 | } |
|
|
1568 | |
1490 | void inline_speed |
1569 | void inline_speed |
1491 | ev_start (EV_P_ W w, int active) |
1570 | ev_start (EV_P_ W w, int active) |
1492 | { |
1571 | { |
1493 | if (w->priority < EV_MINPRI) w->priority = EV_MINPRI; |
1572 | pri_adjust (EV_A_ w); |
1494 | if (w->priority > EV_MAXPRI) w->priority = EV_MAXPRI; |
|
|
1495 | |
|
|
1496 | w->active = active; |
1573 | w->active = active; |
1497 | ev_ref (EV_A); |
1574 | ev_ref (EV_A); |
1498 | } |
1575 | } |
1499 | |
1576 | |
1500 | void inline_size |
1577 | void inline_size |
… | |
… | |
1524 | } |
1601 | } |
1525 | |
1602 | |
1526 | void |
1603 | void |
1527 | ev_io_stop (EV_P_ ev_io *w) |
1604 | ev_io_stop (EV_P_ ev_io *w) |
1528 | { |
1605 | { |
1529 | ev_clear_pending (EV_A_ (W)w); |
1606 | clear_pending (EV_A_ (W)w); |
1530 | if (expect_false (!ev_is_active (w))) |
1607 | if (expect_false (!ev_is_active (w))) |
1531 | return; |
1608 | return; |
1532 | |
1609 | |
1533 | assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)); |
1610 | assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)); |
1534 | |
1611 | |
… | |
… | |
1557 | } |
1634 | } |
1558 | |
1635 | |
1559 | void |
1636 | void |
1560 | ev_timer_stop (EV_P_ ev_timer *w) |
1637 | ev_timer_stop (EV_P_ ev_timer *w) |
1561 | { |
1638 | { |
1562 | ev_clear_pending (EV_A_ (W)w); |
1639 | clear_pending (EV_A_ (W)w); |
1563 | if (expect_false (!ev_is_active (w))) |
1640 | if (expect_false (!ev_is_active (w))) |
1564 | return; |
1641 | return; |
1565 | |
1642 | |
1566 | assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); |
1643 | assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); |
1567 | |
1644 | |
… | |
… | |
1625 | } |
1702 | } |
1626 | |
1703 | |
1627 | void |
1704 | void |
1628 | ev_periodic_stop (EV_P_ ev_periodic *w) |
1705 | ev_periodic_stop (EV_P_ ev_periodic *w) |
1629 | { |
1706 | { |
1630 | ev_clear_pending (EV_A_ (W)w); |
1707 | clear_pending (EV_A_ (W)w); |
1631 | if (expect_false (!ev_is_active (w))) |
1708 | if (expect_false (!ev_is_active (w))) |
1632 | return; |
1709 | return; |
1633 | |
1710 | |
1634 | assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); |
1711 | assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); |
1635 | |
1712 | |
… | |
… | |
1689 | } |
1766 | } |
1690 | |
1767 | |
1691 | void |
1768 | void |
1692 | ev_signal_stop (EV_P_ ev_signal *w) |
1769 | ev_signal_stop (EV_P_ ev_signal *w) |
1693 | { |
1770 | { |
1694 | ev_clear_pending (EV_A_ (W)w); |
1771 | clear_pending (EV_A_ (W)w); |
1695 | if (expect_false (!ev_is_active (w))) |
1772 | if (expect_false (!ev_is_active (w))) |
1696 | return; |
1773 | return; |
1697 | |
1774 | |
1698 | wlist_del ((WL *)&signals [w->signum - 1].head, (WL)w); |
1775 | wlist_del ((WL *)&signals [w->signum - 1].head, (WL)w); |
1699 | ev_stop (EV_A_ (W)w); |
1776 | ev_stop (EV_A_ (W)w); |
… | |
… | |
1716 | } |
1793 | } |
1717 | |
1794 | |
1718 | void |
1795 | void |
1719 | ev_child_stop (EV_P_ ev_child *w) |
1796 | ev_child_stop (EV_P_ ev_child *w) |
1720 | { |
1797 | { |
1721 | ev_clear_pending (EV_A_ (W)w); |
1798 | clear_pending (EV_A_ (W)w); |
1722 | if (expect_false (!ev_is_active (w))) |
1799 | if (expect_false (!ev_is_active (w))) |
1723 | return; |
1800 | return; |
1724 | |
1801 | |
1725 | wlist_del ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
1802 | wlist_del ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
1726 | ev_stop (EV_A_ (W)w); |
1803 | ev_stop (EV_A_ (W)w); |
… | |
… | |
1962 | } |
2039 | } |
1963 | |
2040 | |
1964 | void |
2041 | void |
1965 | ev_stat_stop (EV_P_ ev_stat *w) |
2042 | ev_stat_stop (EV_P_ ev_stat *w) |
1966 | { |
2043 | { |
1967 | ev_clear_pending (EV_A_ (W)w); |
2044 | clear_pending (EV_A_ (W)w); |
1968 | if (expect_false (!ev_is_active (w))) |
2045 | if (expect_false (!ev_is_active (w))) |
1969 | return; |
2046 | return; |
1970 | |
2047 | |
1971 | #if EV_USE_INOTIFY |
2048 | #if EV_USE_INOTIFY |
1972 | infy_del (EV_A_ w); |
2049 | infy_del (EV_A_ w); |
… | |
… | |
1975 | |
2052 | |
1976 | ev_stop (EV_A_ (W)w); |
2053 | ev_stop (EV_A_ (W)w); |
1977 | } |
2054 | } |
1978 | #endif |
2055 | #endif |
1979 | |
2056 | |
|
|
2057 | #if EV_IDLE_ENABLE |
1980 | void |
2058 | void |
1981 | ev_idle_start (EV_P_ ev_idle *w) |
2059 | ev_idle_start (EV_P_ ev_idle *w) |
1982 | { |
2060 | { |
1983 | if (expect_false (ev_is_active (w))) |
2061 | if (expect_false (ev_is_active (w))) |
1984 | return; |
2062 | return; |
1985 | |
2063 | |
|
|
2064 | pri_adjust (EV_A_ (W)w); |
|
|
2065 | |
|
|
2066 | { |
|
|
2067 | int active = ++idlecnt [ABSPRI (w)]; |
|
|
2068 | |
|
|
2069 | ++idleall; |
1986 | ev_start (EV_A_ (W)w, ++idlecnt); |
2070 | ev_start (EV_A_ (W)w, active); |
|
|
2071 | |
1987 | array_needsize (ev_idle *, idles, idlemax, idlecnt, EMPTY2); |
2072 | array_needsize (ev_idle *, idles [ABSPRI (w)], idlemax [ABSPRI (w)], active, EMPTY2); |
1988 | idles [idlecnt - 1] = w; |
2073 | idles [ABSPRI (w)][active - 1] = w; |
|
|
2074 | } |
1989 | } |
2075 | } |
1990 | |
2076 | |
1991 | void |
2077 | void |
1992 | ev_idle_stop (EV_P_ ev_idle *w) |
2078 | ev_idle_stop (EV_P_ ev_idle *w) |
1993 | { |
2079 | { |
1994 | ev_clear_pending (EV_A_ (W)w); |
2080 | clear_pending (EV_A_ (W)w); |
1995 | if (expect_false (!ev_is_active (w))) |
2081 | if (expect_false (!ev_is_active (w))) |
1996 | return; |
2082 | return; |
1997 | |
2083 | |
1998 | { |
2084 | { |
1999 | int active = ((W)w)->active; |
2085 | int active = ((W)w)->active; |
2000 | idles [active - 1] = idles [--idlecnt]; |
2086 | |
|
|
2087 | idles [ABSPRI (w)][active - 1] = idles [ABSPRI (w)][--idlecnt [ABSPRI (w)]]; |
2001 | ((W)idles [active - 1])->active = active; |
2088 | ((W)idles [ABSPRI (w)][active - 1])->active = active; |
|
|
2089 | |
|
|
2090 | ev_stop (EV_A_ (W)w); |
|
|
2091 | --idleall; |
2002 | } |
2092 | } |
2003 | |
|
|
2004 | ev_stop (EV_A_ (W)w); |
|
|
2005 | } |
2093 | } |
|
|
2094 | #endif |
2006 | |
2095 | |
2007 | void |
2096 | void |
2008 | ev_prepare_start (EV_P_ ev_prepare *w) |
2097 | ev_prepare_start (EV_P_ ev_prepare *w) |
2009 | { |
2098 | { |
2010 | if (expect_false (ev_is_active (w))) |
2099 | if (expect_false (ev_is_active (w))) |
… | |
… | |
2016 | } |
2105 | } |
2017 | |
2106 | |
2018 | void |
2107 | void |
2019 | ev_prepare_stop (EV_P_ ev_prepare *w) |
2108 | ev_prepare_stop (EV_P_ ev_prepare *w) |
2020 | { |
2109 | { |
2021 | ev_clear_pending (EV_A_ (W)w); |
2110 | clear_pending (EV_A_ (W)w); |
2022 | if (expect_false (!ev_is_active (w))) |
2111 | if (expect_false (!ev_is_active (w))) |
2023 | return; |
2112 | return; |
2024 | |
2113 | |
2025 | { |
2114 | { |
2026 | int active = ((W)w)->active; |
2115 | int active = ((W)w)->active; |
… | |
… | |
2043 | } |
2132 | } |
2044 | |
2133 | |
2045 | void |
2134 | void |
2046 | ev_check_stop (EV_P_ ev_check *w) |
2135 | ev_check_stop (EV_P_ ev_check *w) |
2047 | { |
2136 | { |
2048 | ev_clear_pending (EV_A_ (W)w); |
2137 | clear_pending (EV_A_ (W)w); |
2049 | if (expect_false (!ev_is_active (w))) |
2138 | if (expect_false (!ev_is_active (w))) |
2050 | return; |
2139 | return; |
2051 | |
2140 | |
2052 | { |
2141 | { |
2053 | int active = ((W)w)->active; |
2142 | int active = ((W)w)->active; |
… | |
… | |
2095 | } |
2184 | } |
2096 | |
2185 | |
2097 | void |
2186 | void |
2098 | ev_embed_stop (EV_P_ ev_embed *w) |
2187 | ev_embed_stop (EV_P_ ev_embed *w) |
2099 | { |
2188 | { |
2100 | ev_clear_pending (EV_A_ (W)w); |
2189 | clear_pending (EV_A_ (W)w); |
2101 | if (expect_false (!ev_is_active (w))) |
2190 | if (expect_false (!ev_is_active (w))) |
2102 | return; |
2191 | return; |
2103 | |
2192 | |
2104 | ev_io_stop (EV_A_ &w->io); |
2193 | ev_io_stop (EV_A_ &w->io); |
2105 | |
2194 | |
… | |
… | |
2120 | } |
2209 | } |
2121 | |
2210 | |
2122 | void |
2211 | void |
2123 | ev_fork_stop (EV_P_ ev_fork *w) |
2212 | ev_fork_stop (EV_P_ ev_fork *w) |
2124 | { |
2213 | { |
2125 | ev_clear_pending (EV_A_ (W)w); |
2214 | clear_pending (EV_A_ (W)w); |
2126 | if (expect_false (!ev_is_active (w))) |
2215 | if (expect_false (!ev_is_active (w))) |
2127 | return; |
2216 | return; |
2128 | |
2217 | |
2129 | { |
2218 | { |
2130 | int active = ((W)w)->active; |
2219 | int active = ((W)w)->active; |