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

Comparing libev/ev.c (file contents):
Revision 1.368 by root, Mon Jan 17 12:11:11 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
1351 char dummy; 1352 char dummy;
1352 /* see discussion in evpipe_write when you think this read should be recv in win32 */ 1353 /* see discussion in evpipe_write when you think this read should be recv in win32 */
1353 read (evpipe [0], &dummy, 1); 1354 read (evpipe [0], &dummy, 1);
1354 } 1355 }
1355 1356
1357#if EV_SIGNAL_ENABLE
1356 if (sig_pending) 1358 if (sig_pending)
1357 { 1359 {
1358 sig_pending = 0; 1360 sig_pending = 0;
1359 1361
1360 for (i = EV_NSIG - 1; i--; ) 1362 for (i = EV_NSIG - 1; i--; )
1361 if (expect_false (signals [i].pending)) 1363 if (expect_false (signals [i].pending))
1362 ev_feed_signal_event (EV_A_ i + 1); 1364 ev_feed_signal_event (EV_A_ i + 1);
1363 } 1365 }
1366#endif
1364 1367
1365#if EV_ASYNC_ENABLE 1368#if EV_ASYNC_ENABLE
1366 if (async_pending) 1369 if (async_pending)
1367 { 1370 {
1368 async_pending = 0; 1371 async_pending = 0;
2189 feed_reverse_done (EV_A_ EV_TIMER); 2192 feed_reverse_done (EV_A_ EV_TIMER);
2190 } 2193 }
2191} 2194}
2192 2195
2193#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
2194/* make periodics pending */ 2206/* make periodics pending */
2195inline_size void 2207inline_size void
2196periodics_reify (EV_P) 2208periodics_reify (EV_P)
2197{ 2209{
2198 EV_FREQUENT_CHECK; 2210 EV_FREQUENT_CHECK;
2217 ANHE_at_cache (periodics [HEAP0]); 2229 ANHE_at_cache (periodics [HEAP0]);
2218 downheap (periodics, periodiccnt, HEAP0); 2230 downheap (periodics, periodiccnt, HEAP0);
2219 } 2231 }
2220 else if (w->interval) 2232 else if (w->interval)
2221 { 2233 {
2222 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; 2234 periodic_recalc (EV_A_ w);
2235
2223 /* 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 */
2224 /* this might happen because of floating point inexactness */ 2237 /* this might happen because of floating point inexactness */
2225 if (ev_at (w) - ev_rt_now < TIME_EPSILON) 2238 if (ev_at (w) - ev_rt_now < TIME_EPSILON)
2226 { 2239 {
2227 ev_at (w) += w->interval; 2240 ev_at (w) += w->interval;
2261 ev_periodic *w = (ev_periodic *)ANHE_w (periodics [i]); 2274 ev_periodic *w = (ev_periodic *)ANHE_w (periodics [i]);
2262 2275
2263 if (w->reschedule_cb) 2276 if (w->reschedule_cb)
2264 ev_at (w) = w->reschedule_cb (w, ev_rt_now); 2277 ev_at (w) = w->reschedule_cb (w, ev_rt_now);
2265 else if (w->interval) 2278 else if (w->interval)
2266 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; 2279 periodic_recalc (EV_A_ w);
2267 2280
2268 ANHE_at_cache (periodics [i]); 2281 ANHE_at_cache (periodics [i]);
2269 } 2282 }
2270 2283
2271 reheap (periodics, periodiccnt); 2284 reheap (periodics, periodiccnt);
2763 if (w->reschedule_cb) 2776 if (w->reschedule_cb)
2764 ev_at (w) = w->reschedule_cb (w, ev_rt_now); 2777 ev_at (w) = w->reschedule_cb (w, ev_rt_now);
2765 else if (w->interval) 2778 else if (w->interval)
2766 { 2779 {
2767 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.));
2768 /* this formula differs from the one in periodic_reify because we do not always round up */ 2781 periodic_recalc (EV_A_ w);
2769 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
2770 } 2782 }
2771 else 2783 else
2772 ev_at (w) = w->offset; 2784 ev_at (w) = w->offset;
2773 2785
2774 EV_FREQUENT_CHECK; 2786 EV_FREQUENT_CHECK;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines