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

Comparing libev/ev.c (file contents):
Revision 1.369 by root, Sun Jan 23 18:53:06 2011 UTC vs.
Revision 1.370 by root, Sun Jan 30 19:05:41 2011 UTC

376# undef EV_USE_INOTIFY 376# undef EV_USE_INOTIFY
377# define EV_USE_INOTIFY 0 377# define EV_USE_INOTIFY 0
378#endif 378#endif
379 379
380#if !EV_USE_NANOSLEEP 380#if !EV_USE_NANOSLEEP
381# ifndef _WIN32 381/* hp-ux has it in sys/time.h, which we unconditionally include above */
382# if !defined(_WIN32) && !defined(__hpux)
382# include <sys/select.h> 383# include <sys/select.h>
383# endif 384# endif
384#endif 385#endif
385 386
386#if EV_USE_INOTIFY 387#if EV_USE_INOTIFY
2191 feed_reverse_done (EV_A_ EV_TIMER); 2192 feed_reverse_done (EV_A_ EV_TIMER);
2192 } 2193 }
2193} 2194}
2194 2195
2195#if EV_PERIODIC_ENABLE 2196#if EV_PERIODIC_ENABLE
2197
2198inline_speed
2199periodic_recalc (EV_P_ ev_periodic *w)
2200{
2201 /* TODO: use slow but potentially more correct incremental algo, */
2202 /* also do not rely on ceil */
2203 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
2204}
2205
2196/* make periodics pending */ 2206/* make periodics pending */
2197inline_size void 2207inline_size void
2198periodics_reify (EV_P) 2208periodics_reify (EV_P)
2199{ 2209{
2200 EV_FREQUENT_CHECK; 2210 EV_FREQUENT_CHECK;
2219 ANHE_at_cache (periodics [HEAP0]); 2229 ANHE_at_cache (periodics [HEAP0]);
2220 downheap (periodics, periodiccnt, HEAP0); 2230 downheap (periodics, periodiccnt, HEAP0);
2221 } 2231 }
2222 else if (w->interval) 2232 else if (w->interval)
2223 { 2233 {
2224 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; 2234 periodic_recalc (EV_A_ w);
2235
2225 /* if next trigger time is not sufficiently in the future, put it there */ 2236 /* if next trigger time is not sufficiently in the future, put it there */
2226 /* this might happen because of floating point inexactness */ 2237 /* this might happen because of floating point inexactness */
2227 if (ev_at (w) - ev_rt_now < TIME_EPSILON) 2238 if (ev_at (w) - ev_rt_now < TIME_EPSILON)
2228 { 2239 {
2229 ev_at (w) += w->interval; 2240 ev_at (w) += w->interval;
2263 ev_periodic *w = (ev_periodic *)ANHE_w (periodics [i]); 2274 ev_periodic *w = (ev_periodic *)ANHE_w (periodics [i]);
2264 2275
2265 if (w->reschedule_cb) 2276 if (w->reschedule_cb)
2266 ev_at (w) = w->reschedule_cb (w, ev_rt_now); 2277 ev_at (w) = w->reschedule_cb (w, ev_rt_now);
2267 else if (w->interval) 2278 else if (w->interval)
2268 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; 2279 periodic_recalc (EV_A_ w);
2269 2280
2270 ANHE_at_cache (periodics [i]); 2281 ANHE_at_cache (periodics [i]);
2271 } 2282 }
2272 2283
2273 reheap (periodics, periodiccnt); 2284 reheap (periodics, periodiccnt);
2765 if (w->reschedule_cb) 2776 if (w->reschedule_cb)
2766 ev_at (w) = w->reschedule_cb (w, ev_rt_now); 2777 ev_at (w) = w->reschedule_cb (w, ev_rt_now);
2767 else if (w->interval) 2778 else if (w->interval)
2768 { 2779 {
2769 assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.)); 2780 assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
2770 /* this formula differs from the one in periodic_reify because we do not always round up */ 2781 periodic_recalc (EV_A_ w);
2771 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
2772 } 2782 }
2773 else 2783 else
2774 ev_at (w) = w->offset; 2784 ev_at (w) = w->offset;
2775 2785
2776 EV_FREQUENT_CHECK; 2786 EV_FREQUENT_CHECK;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines