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

Comparing libev/ev.c (file contents):
Revision 1.241 by root, Fri May 9 13:57:00 2008 UTC vs.
Revision 1.242 by root, Fri May 9 14:07:19 2008 UTC

430 WL head; 430 WL head;
431} ANFS; 431} ANFS;
432#endif 432#endif
433 433
434/* Heap Entry */ 434/* Heap Entry */
435#define EV_HEAP_CACHE_AT 0
435#if EV_HEAP_CACHE_AT 436#if EV_HEAP_CACHE_AT
436 typedef struct { 437 typedef struct {
437 WT w; 438 WT w;
438 ev_tstamp at; 439 ev_tstamp at;
439 } ANHE; 440 } ANHE;
440 441
441 #define ANHE_w(he) (he) /* access watcher, read-write */ 442 #define ANHE_w(he) (he).w /* access watcher, read-write */
442 #define ANHE_at(he) (he)->at /* acces cahced at, read-only */ 443 #define ANHE_at(he) (he).at /* access cached at, read-only */
443 #define ANHE_at_set(he) (he)->at = (he)->w->at /* update at from watcher */ 444 #define ANHE_at_set(he) (he).at = (he).w->at /* update at from watcher */
444#else 445#else
445 typedef WT ANHE; 446 typedef WT ANHE;
446 447
447 #define ANHE_w(he) (he) 448 #define ANHE_w(he) (he)
448 #define ANHE_at(he) (he)->at 449 #define ANHE_at(he) (he)->at
1609 1610
1610 ev_at (w) += w->repeat; 1611 ev_at (w) += w->repeat;
1611 if (ev_at (w) < mn_now) 1612 if (ev_at (w) < mn_now)
1612 ev_at (w) = mn_now; 1613 ev_at (w) = mn_now;
1613 1614
1615 ANHE_at_set (timers [HEAP0]);
1614 downheap (timers, timercnt, HEAP0); 1616 downheap (timers, timercnt, HEAP0);
1615 } 1617 }
1616 else 1618 else
1617 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ 1619 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
1618 1620
1633 /* first reschedule or stop timer */ 1635 /* first reschedule or stop timer */
1634 if (w->reschedule_cb) 1636 if (w->reschedule_cb)
1635 { 1637 {
1636 ev_at (w) = w->reschedule_cb (w, ev_rt_now + TIME_EPSILON); 1638 ev_at (w) = w->reschedule_cb (w, ev_rt_now + TIME_EPSILON);
1637 assert (("ev_periodic reschedule callback returned time in the past", ev_at (w) > ev_rt_now)); 1639 assert (("ev_periodic reschedule callback returned time in the past", ev_at (w) > ev_rt_now));
1640 ANHE_at_set (periodics [HEAP0]);
1638 downheap (periodics, periodiccnt, 1); 1641 downheap (periodics, periodiccnt, HEAP0);
1639 } 1642 }
1640 else if (w->interval) 1643 else if (w->interval)
1641 { 1644 {
1642 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; 1645 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
1643 if (ev_at (w) - ev_rt_now <= TIME_EPSILON) ev_at (w) += w->interval; 1646 if (ev_at (w) - ev_rt_now <= TIME_EPSILON) ev_at (w) += w->interval;
1644 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ev_at (w) > ev_rt_now)); 1647 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ev_at (w) > ev_rt_now));
1648 ANHE_at_set (periodics [HEAP0]);
1645 downheap (periodics, periodiccnt, HEAP0); 1649 downheap (periodics, periodiccnt, HEAP0);
1646 } 1650 }
1647 else 1651 else
1648 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ 1652 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
1649 1653
1663 1667
1664 if (w->reschedule_cb) 1668 if (w->reschedule_cb)
1665 ev_at (w) = w->reschedule_cb (w, ev_rt_now); 1669 ev_at (w) = w->reschedule_cb (w, ev_rt_now);
1666 else if (w->interval) 1670 else if (w->interval)
1667 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; 1671 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
1672
1673 ANHE_at_set (periodics [i]);
1668 } 1674 }
1669 1675
1670 /* now rebuild the heap, this for the 2-heap, inefficient for the 4-heap, but correct */ 1676 /* now rebuild the heap, this for the 2-heap, inefficient for the 4-heap, but correct */
1671 for (i = periodiccnt >> 1; --i; ) 1677 for (i = periodiccnt >> 1; --i; )
1672 downheap (periodics, periodiccnt, i + HEAP0); 1678 downheap (periodics, periodiccnt, i + HEAP0);
1985{ 1991{
1986 clear_pending (EV_A_ (W)w); 1992 clear_pending (EV_A_ (W)w);
1987 if (expect_false (!ev_is_active (w))) 1993 if (expect_false (!ev_is_active (w)))
1988 return; 1994 return;
1989 1995
1990 assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)); 1996 assert (("ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
1991 1997
1992 wlist_del (&anfds[w->fd].head, (WL)w); 1998 wlist_del (&anfds[w->fd].head, (WL)w);
1993 ev_stop (EV_A_ (W)w); 1999 ev_stop (EV_A_ (W)w);
1994 2000
1995 fd_change (EV_A_ w->fd, 1); 2001 fd_change (EV_A_ w->fd, 1);
2009 array_needsize (ANHE, timers, timermax, ev_active (w) + 1, EMPTY2); 2015 array_needsize (ANHE, timers, timermax, ev_active (w) + 1, EMPTY2);
2010 ANHE_w (timers [ev_active (w)]) = (WT)w; 2016 ANHE_w (timers [ev_active (w)]) = (WT)w;
2011 ANHE_at_set (timers [ev_active (w)]); 2017 ANHE_at_set (timers [ev_active (w)]);
2012 upheap (timers, ev_active (w)); 2018 upheap (timers, ev_active (w));
2013 2019
2014 /*assert (("internal timer heap corruption", timers [ev_active (w)] == w));*/ 2020 /*assert (("internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/
2015} 2021}
2016 2022
2017void noinline 2023void noinline
2018ev_timer_stop (EV_P_ ev_timer *w) 2024ev_timer_stop (EV_P_ ev_timer *w)
2019{ 2025{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines