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

Comparing libev/ev.c (file contents):
Revision 1.284 by root, Wed Apr 15 17:49:26 2009 UTC vs.
Revision 1.287 by root, Mon Apr 20 19:45:58 2009 UTC

1896 1896
1897 reheap (periodics, periodiccnt); 1897 reheap (periodics, periodiccnt);
1898} 1898}
1899#endif 1899#endif
1900 1900
1901static void noinline
1902timers_reschedule (EV_P_ ev_tstamp adjust)
1903{
1904 int i;
1905
1906 for (i = 0; i < timercnt; ++i)
1907 {
1908 ANHE *he = timers + i + HEAP0;
1909 ANHE_w (*he)->at += adjust;
1910 ANHE_at_cache (*he);
1911 }
1912}
1913
1901inline_speed void 1914inline_speed void
1902time_update (EV_P_ ev_tstamp max_block) 1915time_update (EV_P_ ev_tstamp max_block)
1903{ 1916{
1904 int i; 1917 int i;
1905 1918
1939 ev_rt_now = ev_time (); 1952 ev_rt_now = ev_time ();
1940 mn_now = get_clock (); 1953 mn_now = get_clock ();
1941 now_floor = mn_now; 1954 now_floor = mn_now;
1942 } 1955 }
1943 1956
1957 /* no timer adjustment, as the monotonic clock doesn't jump */
1958 /* timers_reschedule (EV_A_ rtmn_diff - odiff) */
1944# if EV_PERIODIC_ENABLE 1959# if EV_PERIODIC_ENABLE
1945 periodics_reschedule (EV_A); 1960 periodics_reschedule (EV_A);
1946# endif 1961# endif
1947 /* no timer adjustment, as the monotonic clock doesn't jump */
1948 /* timers_reschedule (EV_A_ rtmn_diff - odiff) */
1949 } 1962 }
1950 else 1963 else
1951#endif 1964#endif
1952 { 1965 {
1953 ev_rt_now = ev_time (); 1966 ev_rt_now = ev_time ();
1954 1967
1955 if (expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP)) 1968 if (expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP))
1956 { 1969 {
1970 /* adjust timers. this is easy, as the offset is the same for all of them */
1971 timers_reschedule (EV_A_ ev_rt_now - mn_now);
1957#if EV_PERIODIC_ENABLE 1972#if EV_PERIODIC_ENABLE
1958 periodics_reschedule (EV_A); 1973 periodics_reschedule (EV_A);
1959#endif 1974#endif
1960 /* adjust timers. this is easy, as the offset is the same for all of them */
1961 for (i = 0; i < timercnt; ++i)
1962 {
1963 ANHE *he = timers + i + HEAP0;
1964 ANHE_w (*he)->at += ev_rt_now - mn_now;
1965 ANHE_at_cache (*he);
1966 }
1967 } 1975 }
1968 1976
1969 mn_now = ev_rt_now; 1977 mn_now = ev_rt_now;
1970 } 1978 }
1971}
1972
1973void
1974ev_ref (EV_P)
1975{
1976 ++activecnt;
1977}
1978
1979void
1980ev_unref (EV_P)
1981{
1982 --activecnt;
1983}
1984
1985void
1986ev_now_update (EV_P)
1987{
1988 time_update (EV_A_ 1e100);
1989} 1979}
1990 1980
1991static int loop_done; 1981static int loop_done;
1992 1982
1993void 1983void
2044 if (expect_true (!(flags & EVLOOP_NONBLOCK || idleall || !activecnt))) 2034 if (expect_true (!(flags & EVLOOP_NONBLOCK || idleall || !activecnt)))
2045 { 2035 {
2046 /* update time to cancel out callback processing overhead */ 2036 /* update time to cancel out callback processing overhead */
2047 time_update (EV_A_ 1e100); 2037 time_update (EV_A_ 1e100);
2048 2038
2039 waittime = MAX_BLOCKTIME;
2040
2049 if (timercnt) 2041 if (timercnt)
2050 { 2042 {
2051 ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now + backend_fudge; 2043 ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now + backend_fudge;
2052 if (waittime > to) waittime = to; 2044 if (waittime > to) waittime = to;
2053 } 2045 }
2111 2103
2112void 2104void
2113ev_unloop (EV_P_ int how) 2105ev_unloop (EV_P_ int how)
2114{ 2106{
2115 loop_done = how; 2107 loop_done = how;
2108}
2109
2110void
2111ev_ref (EV_P)
2112{
2113 ++activecnt;
2114}
2115
2116void
2117ev_unref (EV_P)
2118{
2119 --activecnt;
2120}
2121
2122void
2123ev_now_update (EV_P)
2124{
2125 time_update (EV_A_ 1e100);
2126}
2127
2128void
2129ev_suspend (EV_P)
2130{
2131 ev_now_update (EV_A);
2132}
2133
2134void
2135ev_resume (EV_P)
2136{
2137 ev_tstamp mn_prev = mn_now;
2138
2139 ev_now_update (EV_A);
2140 timers_reschedule (EV_A_ mn_now - mn_prev);
2141#if EV_PERIODIC_ENABLE
2142 periodics_reschedule (EV_A);
2143#endif
2116} 2144}
2117 2145
2118/*****************************************************************************/ 2146/*****************************************************************************/
2119 2147
2120inline_size void 2148inline_size void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines