… | |
… | |
325 | |
325 | |
326 | typedef ev_watcher *W; |
326 | typedef ev_watcher *W; |
327 | typedef ev_watcher_list *WL; |
327 | typedef ev_watcher_list *WL; |
328 | typedef ev_watcher_time *WT; |
328 | typedef ev_watcher_time *WT; |
329 | |
329 | |
|
|
330 | #define ev_active(w) ((W)(w))->active |
|
|
331 | #define ev_at(w) ((WT)(w))->at |
|
|
332 | |
330 | #if EV_USE_MONOTONIC |
333 | #if EV_USE_MONOTONIC |
331 | /* sig_atomic_t is used to avoid per-thread variables or locking but still */ |
334 | /* sig_atomic_t is used to avoid per-thread variables or locking but still */ |
332 | /* giving it a reasonably high chance of working on typical architetcures */ |
335 | /* giving it a reasonably high chance of working on typical architetcures */ |
333 | static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
336 | static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
334 | #endif |
337 | #endif |
… | |
… | |
517 | } |
520 | } |
518 | } |
521 | } |
519 | |
522 | |
520 | /*****************************************************************************/ |
523 | /*****************************************************************************/ |
521 | |
524 | |
|
|
525 | #define MALLOC_ROUND 4096 // prefer to allocate in chunks of this size, must be 2**n and >> 4 longs |
|
|
526 | |
522 | int inline_size |
527 | int inline_size |
523 | array_nextsize (int elem, int cur, int cnt) |
528 | array_nextsize (int elem, int cur, int cnt) |
524 | { |
529 | { |
525 | int ncur = cur + 1; |
530 | int ncur = cur + 1; |
526 | |
531 | |
527 | do |
532 | do |
528 | ncur <<= 1; |
533 | ncur <<= 1; |
529 | while (cnt > ncur); |
534 | while (cnt > ncur); |
530 | |
535 | |
531 | /* if size > 4096, round to 4096 - 4 * longs to accomodate malloc overhead */ |
536 | /* if size is large, round to MALLOC_ROUND - 4 * longs to accomodate malloc overhead */ |
532 | if (elem * ncur > 4096) |
537 | if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) |
533 | { |
538 | { |
534 | ncur *= elem; |
539 | ncur *= elem; |
535 | ncur = (ncur + elem + 4095 + sizeof (void *) * 4) & ~4095; |
540 | ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); |
536 | ncur = ncur - sizeof (void *) * 4; |
541 | ncur = ncur - sizeof (void *) * 4; |
537 | ncur /= elem; |
542 | ncur /= elem; |
538 | } |
543 | } |
539 | |
544 | |
540 | return ncur; |
545 | return ncur; |
… | |
… | |
754 | } |
759 | } |
755 | } |
760 | } |
756 | |
761 | |
757 | /*****************************************************************************/ |
762 | /*****************************************************************************/ |
758 | |
763 | |
|
|
764 | /* towards the root */ |
759 | void inline_speed |
765 | void inline_speed |
760 | upheap (WT *heap, int k) |
766 | upheap (WT *heap, int k) |
761 | { |
767 | { |
762 | WT w = heap [k]; |
768 | WT w = heap [k]; |
763 | |
769 | |
764 | while (k) |
770 | for (;;) |
765 | { |
771 | { |
766 | int p = (k - 1) >> 1; |
772 | int p = k >> 1; |
767 | |
773 | |
|
|
774 | /* maybe we could use a dummy element at heap [0]? */ |
768 | if (heap [p]->at <= w->at) |
775 | if (!p || heap [p]->at <= w->at) |
769 | break; |
776 | break; |
770 | |
777 | |
771 | heap [k] = heap [p]; |
778 | heap [k] = heap [p]; |
772 | ((W)heap [k])->active = k + 1; |
779 | ev_active (heap [k]) = k; |
773 | k = p; |
780 | k = p; |
774 | } |
781 | } |
775 | |
782 | |
776 | heap [k] = w; |
783 | heap [k] = w; |
777 | ((W)heap [k])->active = k + 1; |
784 | ev_active (heap [k]) = k; |
778 | } |
785 | } |
779 | |
786 | |
|
|
787 | /* away from the root */ |
780 | void inline_speed |
788 | void inline_speed |
781 | downheap (WT *heap, int N, int k) |
789 | downheap (WT *heap, int N, int k) |
782 | { |
790 | { |
783 | WT w = heap [k]; |
791 | WT w = heap [k]; |
784 | |
792 | |
785 | for (;;) |
793 | for (;;) |
786 | { |
794 | { |
787 | int c = (k << 1) + 1; |
795 | int c = k << 1; |
788 | |
796 | |
789 | if (c >= N) |
797 | if (c > N) |
790 | break; |
798 | break; |
791 | |
799 | |
792 | c += c + 1 < N && heap [c]->at > heap [c + 1]->at |
800 | c += c < N && heap [c]->at > heap [c + 1]->at |
793 | ? 1 : 0; |
801 | ? 1 : 0; |
794 | |
802 | |
795 | if (w->at <= heap [c]->at) |
803 | if (w->at <= heap [c]->at) |
796 | break; |
804 | break; |
797 | |
805 | |
798 | heap [k] = heap [c]; |
806 | heap [k] = heap [c]; |
799 | ((W)heap [k])->active = k + 1; |
807 | ev_active (heap [k]) = k; |
800 | |
808 | |
801 | k = c; |
809 | k = c; |
802 | } |
810 | } |
803 | |
811 | |
804 | heap [k] = w; |
812 | heap [k] = w; |
805 | ((W)heap [k])->active = k + 1; |
813 | ev_active (heap [k]) = k; |
806 | } |
814 | } |
807 | |
815 | |
808 | void inline_size |
816 | void inline_size |
809 | adjustheap (WT *heap, int N, int k) |
817 | adjustheap (WT *heap, int N, int k) |
810 | { |
818 | { |
… | |
… | |
906 | pipecb (EV_P_ ev_io *iow, int revents) |
914 | pipecb (EV_P_ ev_io *iow, int revents) |
907 | { |
915 | { |
908 | #if EV_USE_EVENTFD |
916 | #if EV_USE_EVENTFD |
909 | if (evfd >= 0) |
917 | if (evfd >= 0) |
910 | { |
918 | { |
911 | uint64_t counter = 1; |
919 | uint64_t counter; |
912 | read (evfd, &counter, sizeof (uint64_t)); |
920 | read (evfd, &counter, sizeof (uint64_t)); |
913 | } |
921 | } |
914 | else |
922 | else |
915 | #endif |
923 | #endif |
916 | { |
924 | { |
… | |
… | |
1456 | } |
1464 | } |
1457 | |
1465 | |
1458 | void inline_size |
1466 | void inline_size |
1459 | timers_reify (EV_P) |
1467 | timers_reify (EV_P) |
1460 | { |
1468 | { |
1461 | while (timercnt && ((WT)timers [0])->at <= mn_now) |
1469 | while (timercnt && ev_at (timers [1]) <= mn_now) |
1462 | { |
1470 | { |
1463 | ev_timer *w = (ev_timer *)timers [0]; |
1471 | ev_timer *w = (ev_timer *)timers [1]; |
1464 | |
1472 | |
1465 | /*assert (("inactive timer on timer heap detected", ev_is_active (w)));*/ |
1473 | /*assert (("inactive timer on timer heap detected", ev_is_active (w)));*/ |
1466 | |
1474 | |
1467 | /* first reschedule or stop timer */ |
1475 | /* first reschedule or stop timer */ |
1468 | if (w->repeat) |
1476 | if (w->repeat) |
1469 | { |
1477 | { |
1470 | assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.)); |
1478 | assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.)); |
1471 | |
1479 | |
1472 | ((WT)w)->at += w->repeat; |
1480 | ev_at (w) += w->repeat; |
1473 | if (((WT)w)->at < mn_now) |
1481 | if (ev_at (w) < mn_now) |
1474 | ((WT)w)->at = mn_now; |
1482 | ev_at (w) = mn_now; |
1475 | |
1483 | |
1476 | downheap (timers, timercnt, 0); |
1484 | downheap (timers, timercnt, 1); |
1477 | } |
1485 | } |
1478 | else |
1486 | else |
1479 | ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ |
1487 | ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ |
1480 | |
1488 | |
1481 | ev_feed_event (EV_A_ (W)w, EV_TIMEOUT); |
1489 | ev_feed_event (EV_A_ (W)w, EV_TIMEOUT); |
… | |
… | |
1484 | |
1492 | |
1485 | #if EV_PERIODIC_ENABLE |
1493 | #if EV_PERIODIC_ENABLE |
1486 | void inline_size |
1494 | void inline_size |
1487 | periodics_reify (EV_P) |
1495 | periodics_reify (EV_P) |
1488 | { |
1496 | { |
1489 | while (periodiccnt && ((WT)periodics [0])->at <= ev_rt_now) |
1497 | while (periodiccnt && ev_at (periodics [1]) <= ev_rt_now) |
1490 | { |
1498 | { |
1491 | ev_periodic *w = (ev_periodic *)periodics [0]; |
1499 | ev_periodic *w = (ev_periodic *)periodics [1]; |
1492 | |
1500 | |
1493 | /*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/ |
1501 | /*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/ |
1494 | |
1502 | |
1495 | /* first reschedule or stop timer */ |
1503 | /* first reschedule or stop timer */ |
1496 | if (w->reschedule_cb) |
1504 | if (w->reschedule_cb) |
1497 | { |
1505 | { |
1498 | ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + TIME_EPSILON); |
1506 | ev_at (w) = w->reschedule_cb (w, ev_rt_now + TIME_EPSILON); |
1499 | assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > ev_rt_now)); |
1507 | assert (("ev_periodic reschedule callback returned time in the past", ev_at (w) > ev_rt_now)); |
1500 | downheap (periodics, periodiccnt, 0); |
1508 | downheap (periodics, periodiccnt, 1); |
1501 | } |
1509 | } |
1502 | else if (w->interval) |
1510 | else if (w->interval) |
1503 | { |
1511 | { |
1504 | ((WT)w)->at = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; |
1512 | ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; |
1505 | if (((WT)w)->at - ev_rt_now <= TIME_EPSILON) ((WT)w)->at += w->interval; |
1513 | if (ev_at (w) - ev_rt_now <= TIME_EPSILON) ev_at (w) += w->interval; |
1506 | assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > ev_rt_now)); |
1514 | assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ev_at (w) > ev_rt_now)); |
1507 | downheap (periodics, periodiccnt, 0); |
1515 | downheap (periodics, periodiccnt, 1); |
1508 | } |
1516 | } |
1509 | else |
1517 | else |
1510 | ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ |
1518 | ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ |
1511 | |
1519 | |
1512 | ev_feed_event (EV_A_ (W)w, EV_PERIODIC); |
1520 | ev_feed_event (EV_A_ (W)w, EV_PERIODIC); |
… | |
… | |
1517 | periodics_reschedule (EV_P) |
1525 | periodics_reschedule (EV_P) |
1518 | { |
1526 | { |
1519 | int i; |
1527 | int i; |
1520 | |
1528 | |
1521 | /* adjust periodics after time jump */ |
1529 | /* adjust periodics after time jump */ |
1522 | for (i = 0; i < periodiccnt; ++i) |
1530 | for (i = 1; i <= periodiccnt; ++i) |
1523 | { |
1531 | { |
1524 | ev_periodic *w = (ev_periodic *)periodics [i]; |
1532 | ev_periodic *w = (ev_periodic *)periodics [i]; |
1525 | |
1533 | |
1526 | if (w->reschedule_cb) |
1534 | if (w->reschedule_cb) |
1527 | ((WT)w)->at = w->reschedule_cb (w, ev_rt_now); |
1535 | ev_at (w) = w->reschedule_cb (w, ev_rt_now); |
1528 | else if (w->interval) |
1536 | else if (w->interval) |
1529 | ((WT)w)->at = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; |
1537 | ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; |
1530 | } |
1538 | } |
1531 | |
1539 | |
1532 | /* now rebuild the heap */ |
1540 | /* now rebuild the heap */ |
1533 | for (i = periodiccnt >> 1; i--; ) |
1541 | for (i = periodiccnt >> 1; i--; ) |
1534 | downheap (periodics, periodiccnt, i); |
1542 | downheap (periodics, periodiccnt, i); |
… | |
… | |
1616 | { |
1624 | { |
1617 | #if EV_PERIODIC_ENABLE |
1625 | #if EV_PERIODIC_ENABLE |
1618 | periodics_reschedule (EV_A); |
1626 | periodics_reschedule (EV_A); |
1619 | #endif |
1627 | #endif |
1620 | /* adjust timers. this is easy, as the offset is the same for all of them */ |
1628 | /* adjust timers. this is easy, as the offset is the same for all of them */ |
1621 | for (i = 0; i < timercnt; ++i) |
1629 | for (i = 1; i <= timercnt; ++i) |
1622 | ((WT)timers [i])->at += ev_rt_now - mn_now; |
1630 | ev_at (timers [i]) += ev_rt_now - mn_now; |
1623 | } |
1631 | } |
1624 | |
1632 | |
1625 | mn_now = ev_rt_now; |
1633 | mn_now = ev_rt_now; |
1626 | } |
1634 | } |
1627 | } |
1635 | } |
… | |
… | |
1697 | |
1705 | |
1698 | waittime = MAX_BLOCKTIME; |
1706 | waittime = MAX_BLOCKTIME; |
1699 | |
1707 | |
1700 | if (timercnt) |
1708 | if (timercnt) |
1701 | { |
1709 | { |
1702 | ev_tstamp to = ((WT)timers [0])->at - mn_now + backend_fudge; |
1710 | ev_tstamp to = ev_at (timers [1]) - mn_now + backend_fudge; |
1703 | if (waittime > to) waittime = to; |
1711 | if (waittime > to) waittime = to; |
1704 | } |
1712 | } |
1705 | |
1713 | |
1706 | #if EV_PERIODIC_ENABLE |
1714 | #if EV_PERIODIC_ENABLE |
1707 | if (periodiccnt) |
1715 | if (periodiccnt) |
1708 | { |
1716 | { |
1709 | ev_tstamp to = ((WT)periodics [0])->at - ev_rt_now + backend_fudge; |
1717 | ev_tstamp to = ev_at (periodics [1]) - ev_rt_now + backend_fudge; |
1710 | if (waittime > to) waittime = to; |
1718 | if (waittime > to) waittime = to; |
1711 | } |
1719 | } |
1712 | #endif |
1720 | #endif |
1713 | |
1721 | |
1714 | if (expect_false (waittime < timeout_blocktime)) |
1722 | if (expect_false (waittime < timeout_blocktime)) |
… | |
… | |
1880 | ev_timer_start (EV_P_ ev_timer *w) |
1888 | ev_timer_start (EV_P_ ev_timer *w) |
1881 | { |
1889 | { |
1882 | if (expect_false (ev_is_active (w))) |
1890 | if (expect_false (ev_is_active (w))) |
1883 | return; |
1891 | return; |
1884 | |
1892 | |
1885 | ((WT)w)->at += mn_now; |
1893 | ev_at (w) += mn_now; |
1886 | |
1894 | |
1887 | assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); |
1895 | assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); |
1888 | |
1896 | |
1889 | ev_start (EV_A_ (W)w, ++timercnt); |
1897 | ev_start (EV_A_ (W)w, ++timercnt); |
1890 | array_needsize (WT, timers, timermax, timercnt, EMPTY2); |
1898 | array_needsize (WT, timers, timermax, timercnt + 1, EMPTY2); |
1891 | timers [timercnt - 1] = (WT)w; |
1899 | timers [timercnt] = (WT)w; |
1892 | upheap (timers, timercnt - 1); |
1900 | upheap (timers, timercnt); |
1893 | |
1901 | |
1894 | /*assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));*/ |
1902 | /*assert (("internal timer heap corruption", timers [ev_active (w)] == w));*/ |
1895 | } |
1903 | } |
1896 | |
1904 | |
1897 | void noinline |
1905 | void noinline |
1898 | ev_timer_stop (EV_P_ ev_timer *w) |
1906 | ev_timer_stop (EV_P_ ev_timer *w) |
1899 | { |
1907 | { |
1900 | clear_pending (EV_A_ (W)w); |
1908 | clear_pending (EV_A_ (W)w); |
1901 | if (expect_false (!ev_is_active (w))) |
1909 | if (expect_false (!ev_is_active (w))) |
1902 | return; |
1910 | return; |
1903 | |
1911 | |
1904 | assert (("internal timer heap corruption", timers [((W)w)->active - 1] == (WT)w)); |
|
|
1905 | |
|
|
1906 | { |
1912 | { |
1907 | int active = ((W)w)->active; |
1913 | int active = ev_active (w); |
1908 | |
1914 | |
|
|
1915 | assert (("internal timer heap corruption", timers [active] == (WT)w)); |
|
|
1916 | |
1909 | if (expect_true (--active < --timercnt)) |
1917 | if (expect_true (active < timercnt)) |
1910 | { |
1918 | { |
1911 | timers [active] = timers [timercnt]; |
1919 | timers [active] = timers [timercnt]; |
1912 | adjustheap (timers, timercnt, active); |
1920 | adjustheap (timers, timercnt, active); |
1913 | } |
1921 | } |
|
|
1922 | |
|
|
1923 | --timercnt; |
1914 | } |
1924 | } |
1915 | |
1925 | |
1916 | ((WT)w)->at -= mn_now; |
1926 | ev_at (w) -= mn_now; |
1917 | |
1927 | |
1918 | ev_stop (EV_A_ (W)w); |
1928 | ev_stop (EV_A_ (W)w); |
1919 | } |
1929 | } |
1920 | |
1930 | |
1921 | void noinline |
1931 | void noinline |
… | |
… | |
1923 | { |
1933 | { |
1924 | if (ev_is_active (w)) |
1934 | if (ev_is_active (w)) |
1925 | { |
1935 | { |
1926 | if (w->repeat) |
1936 | if (w->repeat) |
1927 | { |
1937 | { |
1928 | ((WT)w)->at = mn_now + w->repeat; |
1938 | ev_at (w) = mn_now + w->repeat; |
1929 | adjustheap (timers, timercnt, ((W)w)->active - 1); |
1939 | adjustheap (timers, timercnt, ev_active (w)); |
1930 | } |
1940 | } |
1931 | else |
1941 | else |
1932 | ev_timer_stop (EV_A_ w); |
1942 | ev_timer_stop (EV_A_ w); |
1933 | } |
1943 | } |
1934 | else if (w->repeat) |
1944 | else if (w->repeat) |
1935 | { |
1945 | { |
1936 | w->at = w->repeat; |
1946 | ev_at (w) = w->repeat; |
1937 | ev_timer_start (EV_A_ w); |
1947 | ev_timer_start (EV_A_ w); |
1938 | } |
1948 | } |
1939 | } |
1949 | } |
1940 | |
1950 | |
1941 | #if EV_PERIODIC_ENABLE |
1951 | #if EV_PERIODIC_ENABLE |
… | |
… | |
1944 | { |
1954 | { |
1945 | if (expect_false (ev_is_active (w))) |
1955 | if (expect_false (ev_is_active (w))) |
1946 | return; |
1956 | return; |
1947 | |
1957 | |
1948 | if (w->reschedule_cb) |
1958 | if (w->reschedule_cb) |
1949 | ((WT)w)->at = w->reschedule_cb (w, ev_rt_now); |
1959 | ev_at (w) = w->reschedule_cb (w, ev_rt_now); |
1950 | else if (w->interval) |
1960 | else if (w->interval) |
1951 | { |
1961 | { |
1952 | assert (("ev_periodic_start called with negative interval value", w->interval >= 0.)); |
1962 | assert (("ev_periodic_start called with negative interval value", w->interval >= 0.)); |
1953 | /* this formula differs from the one in periodic_reify because we do not always round up */ |
1963 | /* this formula differs from the one in periodic_reify because we do not always round up */ |
1954 | ((WT)w)->at = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; |
1964 | ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; |
1955 | } |
1965 | } |
1956 | else |
1966 | else |
1957 | ((WT)w)->at = w->offset; |
1967 | ev_at (w) = w->offset; |
1958 | |
1968 | |
1959 | ev_start (EV_A_ (W)w, ++periodiccnt); |
1969 | ev_start (EV_A_ (W)w, ++periodiccnt); |
1960 | array_needsize (WT, periodics, periodicmax, periodiccnt, EMPTY2); |
1970 | array_needsize (WT, periodics, periodicmax, periodiccnt + 1, EMPTY2); |
1961 | periodics [periodiccnt - 1] = (WT)w; |
1971 | periodics [periodiccnt] = (WT)w; |
1962 | upheap (periodics, periodiccnt - 1); |
1972 | upheap (periodics, periodiccnt); |
1963 | |
1973 | |
1964 | /*assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));*/ |
1974 | /*assert (("internal periodic heap corruption", periodics [ev_active (w)] == w));*/ |
1965 | } |
1975 | } |
1966 | |
1976 | |
1967 | void noinline |
1977 | void noinline |
1968 | ev_periodic_stop (EV_P_ ev_periodic *w) |
1978 | ev_periodic_stop (EV_P_ ev_periodic *w) |
1969 | { |
1979 | { |
1970 | clear_pending (EV_A_ (W)w); |
1980 | clear_pending (EV_A_ (W)w); |
1971 | if (expect_false (!ev_is_active (w))) |
1981 | if (expect_false (!ev_is_active (w))) |
1972 | return; |
1982 | return; |
1973 | |
1983 | |
1974 | assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == (WT)w)); |
|
|
1975 | |
|
|
1976 | { |
1984 | { |
1977 | int active = ((W)w)->active; |
1985 | int active = ev_active (w); |
1978 | |
1986 | |
|
|
1987 | assert (("internal periodic heap corruption", periodics [active] == (WT)w)); |
|
|
1988 | |
1979 | if (expect_true (--active < --periodiccnt)) |
1989 | if (expect_true (active < periodiccnt)) |
1980 | { |
1990 | { |
1981 | periodics [active] = periodics [periodiccnt]; |
1991 | periodics [active] = periodics [periodiccnt]; |
1982 | adjustheap (periodics, periodiccnt, active); |
1992 | adjustheap (periodics, periodiccnt, active); |
1983 | } |
1993 | } |
|
|
1994 | |
|
|
1995 | --periodiccnt; |
1984 | } |
1996 | } |
1985 | |
1997 | |
1986 | ev_stop (EV_A_ (W)w); |
1998 | ev_stop (EV_A_ (W)w); |
1987 | } |
1999 | } |
1988 | |
2000 | |
… | |
… | |
2358 | clear_pending (EV_A_ (W)w); |
2370 | clear_pending (EV_A_ (W)w); |
2359 | if (expect_false (!ev_is_active (w))) |
2371 | if (expect_false (!ev_is_active (w))) |
2360 | return; |
2372 | return; |
2361 | |
2373 | |
2362 | { |
2374 | { |
2363 | int active = ((W)w)->active; |
2375 | int active = ev_active (w); |
2364 | |
2376 | |
2365 | idles [ABSPRI (w)][active - 1] = idles [ABSPRI (w)][--idlecnt [ABSPRI (w)]]; |
2377 | idles [ABSPRI (w)][active - 1] = idles [ABSPRI (w)][--idlecnt [ABSPRI (w)]]; |
2366 | ((W)idles [ABSPRI (w)][active - 1])->active = active; |
2378 | ev_active (idles [ABSPRI (w)][active - 1]) = active; |
2367 | |
2379 | |
2368 | ev_stop (EV_A_ (W)w); |
2380 | ev_stop (EV_A_ (W)w); |
2369 | --idleall; |
2381 | --idleall; |
2370 | } |
2382 | } |
2371 | } |
2383 | } |
… | |
… | |
2388 | clear_pending (EV_A_ (W)w); |
2400 | clear_pending (EV_A_ (W)w); |
2389 | if (expect_false (!ev_is_active (w))) |
2401 | if (expect_false (!ev_is_active (w))) |
2390 | return; |
2402 | return; |
2391 | |
2403 | |
2392 | { |
2404 | { |
2393 | int active = ((W)w)->active; |
2405 | int active = ev_active (w); |
|
|
2406 | |
2394 | prepares [active - 1] = prepares [--preparecnt]; |
2407 | prepares [active - 1] = prepares [--preparecnt]; |
2395 | ((W)prepares [active - 1])->active = active; |
2408 | ev_active (prepares [active - 1]) = active; |
2396 | } |
2409 | } |
2397 | |
2410 | |
2398 | ev_stop (EV_A_ (W)w); |
2411 | ev_stop (EV_A_ (W)w); |
2399 | } |
2412 | } |
2400 | |
2413 | |
… | |
… | |
2415 | clear_pending (EV_A_ (W)w); |
2428 | clear_pending (EV_A_ (W)w); |
2416 | if (expect_false (!ev_is_active (w))) |
2429 | if (expect_false (!ev_is_active (w))) |
2417 | return; |
2430 | return; |
2418 | |
2431 | |
2419 | { |
2432 | { |
2420 | int active = ((W)w)->active; |
2433 | int active = ev_active (w); |
|
|
2434 | |
2421 | checks [active - 1] = checks [--checkcnt]; |
2435 | checks [active - 1] = checks [--checkcnt]; |
2422 | ((W)checks [active - 1])->active = active; |
2436 | ev_active (checks [active - 1]) = active; |
2423 | } |
2437 | } |
2424 | |
2438 | |
2425 | ev_stop (EV_A_ (W)w); |
2439 | ev_stop (EV_A_ (W)w); |
2426 | } |
2440 | } |
2427 | |
2441 | |
… | |
… | |
2523 | clear_pending (EV_A_ (W)w); |
2537 | clear_pending (EV_A_ (W)w); |
2524 | if (expect_false (!ev_is_active (w))) |
2538 | if (expect_false (!ev_is_active (w))) |
2525 | return; |
2539 | return; |
2526 | |
2540 | |
2527 | { |
2541 | { |
2528 | int active = ((W)w)->active; |
2542 | int active = ev_active (w); |
|
|
2543 | |
2529 | forks [active - 1] = forks [--forkcnt]; |
2544 | forks [active - 1] = forks [--forkcnt]; |
2530 | ((W)forks [active - 1])->active = active; |
2545 | ev_active (forks [active - 1]) = active; |
2531 | } |
2546 | } |
2532 | |
2547 | |
2533 | ev_stop (EV_A_ (W)w); |
2548 | ev_stop (EV_A_ (W)w); |
2534 | } |
2549 | } |
2535 | #endif |
2550 | #endif |
… | |
… | |
2554 | clear_pending (EV_A_ (W)w); |
2569 | clear_pending (EV_A_ (W)w); |
2555 | if (expect_false (!ev_is_active (w))) |
2570 | if (expect_false (!ev_is_active (w))) |
2556 | return; |
2571 | return; |
2557 | |
2572 | |
2558 | { |
2573 | { |
2559 | int active = ((W)w)->active; |
2574 | int active = ev_active (w); |
|
|
2575 | |
2560 | asyncs [active - 1] = asyncs [--asynccnt]; |
2576 | asyncs [active - 1] = asyncs [--asynccnt]; |
2561 | ((W)asyncs [active - 1])->active = active; |
2577 | ev_active (asyncs [active - 1]) = active; |
2562 | } |
2578 | } |
2563 | |
2579 | |
2564 | ev_stop (EV_A_ (W)w); |
2580 | ev_stop (EV_A_ (W)w); |
2565 | } |
2581 | } |
2566 | |
2582 | |