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

Comparing libev/ev.c (file contents):
Revision 1.175 by root, Tue Dec 11 04:08:54 2007 UTC vs.
Revision 1.176 by root, Tue Dec 11 04:31:55 2007 UTC

216# include <sys/inotify.h> 216# include <sys/inotify.h>
217#endif 217#endif
218 218
219/**/ 219/**/
220 220
221/*
222 * This is used to avoid floating point rounding problems.
223 * It is added to ev_rt_now when scheduling periodics
224 * to ensure progress, time-wise, even when rounding
225 * errors are against us.
226 * This value is good at least till the year 4000
227 * and intervals up to 20 years.
228 * Better solutions welcome.
229 */
230#define TIME_EPSILON 0.0001220703125 /* 1/8192 */
231
221#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ 232#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */
222#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */ 233#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */
223/*#define CLEANUP_INTERVAL (MAX_BLOCKTIME * 5.) /* how often to try to free memory and re-check fds */ 234/*#define CLEANUP_INTERVAL (MAX_BLOCKTIME * 5.) /* how often to try to free memory and re-check fds, TODO */
224 235
225#if __GNUC__ >= 3 236#if __GNUC__ >= 3
226# define expect(expr,value) __builtin_expect ((expr),(value)) 237# define expect(expr,value) __builtin_expect ((expr),(value))
227# define noinline __attribute__ ((noinline)) 238# define noinline __attribute__ ((noinline))
228#else 239#else
1231 /*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/ 1242 /*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/
1232 1243
1233 /* first reschedule or stop timer */ 1244 /* first reschedule or stop timer */
1234 if (w->reschedule_cb) 1245 if (w->reschedule_cb)
1235 { 1246 {
1236 ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + 0.0001220703125 /* 1/8192 */); 1247 ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + TIME_EPSILON);
1237 assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > ev_rt_now)); 1248 assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > ev_rt_now));
1238 downheap ((WT *)periodics, periodiccnt, 0); 1249 downheap ((WT *)periodics, periodiccnt, 0);
1239 } 1250 }
1240 else if (w->interval) 1251 else if (w->interval)
1241 { 1252 {
1242 ((WT)w)->at = w->offset + (floor ((ev_rt_now - w->offset) / w->interval) + 1.) * w->interval; 1253 ((WT)w)->at = w->offset + floor ((ev_rt_now + TIME_EPSILON - w->offset) / w->interval + 1.) * w->interval;
1243 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > ev_rt_now)); 1254 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > ev_rt_now));
1244 downheap ((WT *)periodics, periodiccnt, 0); 1255 downheap ((WT *)periodics, periodiccnt, 0);
1245 } 1256 }
1246 else 1257 else
1247 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ 1258 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines