… | |
… | |
841 | ANHE *pos = heap + DHEAP * (k - HEAP0) + HEAP0; |
841 | ANHE *pos = heap + DHEAP * (k - HEAP0) + HEAP0; |
842 | |
842 | |
843 | // find minimum child |
843 | // find minimum child |
844 | if (expect_true (pos + DHEAP - 1 < E)) |
844 | if (expect_true (pos + DHEAP - 1 < E)) |
845 | { |
845 | { |
846 | /* fast path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); |
846 | /* fast path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); |
847 | if (ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); |
847 | if ( ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); |
848 | if (ANHE_at (pos [2]) < minat) (minpos = pos + 2), (minat = ANHE_at (*minpos)); |
848 | if ( ANHE_at (pos [2]) < minat) (minpos = pos + 2), (minat = ANHE_at (*minpos)); |
849 | if (ANHE_at (pos [3]) < minat) (minpos = pos + 3), (minat = ANHE_at (*minpos)); |
849 | if ( ANHE_at (pos [3]) < minat) (minpos = pos + 3), (minat = ANHE_at (*minpos)); |
850 | } |
850 | } |
851 | else if (pos < E) |
851 | else if (pos < E) |
852 | { |
852 | { |
853 | /* slow path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); |
853 | /* slow path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); |
854 | if (pos + 1 < E && ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); |
854 | if (pos + 1 < E && ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); |
… | |
… | |
1649 | downheap (periodics, periodiccnt, HEAP0); |
1649 | downheap (periodics, periodiccnt, HEAP0); |
1650 | } |
1650 | } |
1651 | else if (w->interval) |
1651 | else if (w->interval) |
1652 | { |
1652 | { |
1653 | ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; |
1653 | ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; |
|
|
1654 | /* if next trigger time is not sufficiently in the future, put it there */ |
|
|
1655 | /* this might happen because of floating point inexactness */ |
1654 | if (ev_at (w) - ev_rt_now <= TIME_EPSILON) ev_at (w) += w->interval; |
1656 | if (ev_at (w) - ev_rt_now < TIME_EPSILON) |
|
|
1657 | { |
|
|
1658 | ev_at (w) += w->interval; |
1655 | |
1659 | |
1656 | assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ev_at (w) >= ev_rt_now)); |
1660 | /* if interval is unreasonably low we might still have a time in the past */ |
|
|
1661 | /* so correct this. this will make the periodic very inexact, but the user */ |
|
|
1662 | /* has effectively asked to get triggered more often than possible */ |
|
|
1663 | if (ev_at (w) < ev_rt_now) |
|
|
1664 | ev_at (w) = ev_rt_now; |
|
|
1665 | } |
1657 | |
1666 | |
1658 | ANHE_at_set (periodics [HEAP0]); |
1667 | ANHE_at_set (periodics [HEAP0]); |
1659 | downheap (periodics, periodiccnt, HEAP0); |
1668 | downheap (periodics, periodiccnt, HEAP0); |
1660 | } |
1669 | } |
1661 | else |
1670 | else |