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

Comparing libev/ev.c (file contents):
Revision 1.243 by root, Fri May 9 15:52:13 2008 UTC vs.
Revision 1.246 by root, Wed May 21 12:51:38 2008 UTC

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));
1601#endif 1601#endif
1602 1602
1603void inline_size 1603void inline_size
1604timers_reify (EV_P) 1604timers_reify (EV_P)
1605{ 1605{
1606 while (timercnt && ANHE_at (timers [HEAP0]) <= mn_now) 1606 while (timercnt && ANHE_at (timers [HEAP0]) < mn_now)
1607 { 1607 {
1608 ev_timer *w = (ev_timer *)ANHE_w (timers [HEAP0]); 1608 ev_timer *w = (ev_timer *)ANHE_w (timers [HEAP0]);
1609 1609
1610 /*assert (("inactive timer on timer heap detected", ev_is_active (w)));*/ 1610 /*assert (("inactive timer on timer heap detected", ev_is_active (w)));*/
1611 1611
1630 1630
1631#if EV_PERIODIC_ENABLE 1631#if EV_PERIODIC_ENABLE
1632void inline_size 1632void inline_size
1633periodics_reify (EV_P) 1633periodics_reify (EV_P)
1634{ 1634{
1635 while (periodiccnt && ANHE_at (periodics [HEAP0]) <= ev_rt_now) 1635 while (periodiccnt && ANHE_at (periodics [HEAP0]) < ev_rt_now)
1636 { 1636 {
1637 ev_periodic *w = (ev_periodic *)ANHE_w (periodics [HEAP0]); 1637 ev_periodic *w = (ev_periodic *)ANHE_w (periodics [HEAP0]);
1638 1638
1639 /*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/ 1639 /*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/
1640 1640
1641 /* first reschedule or stop timer */ 1641 /* first reschedule or stop timer */
1642 if (w->reschedule_cb) 1642 if (w->reschedule_cb)
1643 { 1643 {
1644 ev_at (w) = w->reschedule_cb (w, ev_rt_now + TIME_EPSILON); 1644 ev_at (w) = w->reschedule_cb (w, ev_rt_now);
1645 1645
1646 assert (("ev_periodic reschedule callback returned time in the past", ev_at (w) > ev_rt_now)); 1646 assert (("ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
1647 1647
1648 ANHE_at_set (periodics [HEAP0]); 1648 ANHE_at_set (periodics [HEAP0]);
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines