diff options
author | root <root> | 2009-06-29 18:46:52 +0000 |
---|---|---|
committer | root <root> | 2009-06-29 18:46:52 +0000 |
commit | 0ca732a60d2a2fa1d0fd7526aa267cf0267ed7fc (patch) | |
tree | 2e9eeabca8cd1416ec8236c2fe5ae9abfdfad68c | |
parent | cf2cdd94c999e9df780941b8193335f09d3582df (diff) |
*** empty log message ***
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | ev.c | 24 |
2 files changed, 18 insertions, 8 deletions
@@ -3,7 +3,9 @@ Revision history for libev, a high-performance and full-featured event loop. TODO: ev_walk TODO: child wactehr execution order w.r.t. childsigcb reg. priorities TODO: remain +TODO: io_collect documentation - Denis F. Latypoff corrected many typos in example code snippets. + - the ev_set_io_collect_interval interpretation has changed. - honor autoconf detection of EV_USE_CLOCK_SYSCALL, also double- check that the syscall number is available before trying to use it (reported by ry@tinyclouds). @@ -629,7 +629,7 @@ ev_sleep (ev_tstamp delay) tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6); /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */ - /* somehting nto guaranteed by newer posix versions, but guaranteed */ + /* somehting not guaranteed by newer posix versions, but guaranteed */ /* by older ones */ select (0, 0, 0, 0, &tv); #endif @@ -2077,6 +2077,9 @@ ev_loop (EV_P_ int flags) if (expect_true (!(flags & EVLOOP_NONBLOCK || idleall || !activecnt))) { + /* remember old timestamp for io_blocktime calculation */ + ev_tstamp prev_mn_now = mn_now; + /* update time to cancel out callback processing overhead */ time_update (EV_A_ 1e100); @@ -2096,18 +2099,23 @@ ev_loop (EV_P_ int flags) } #endif + /* don't let timeouts decrease the waittime below timeout_blocktime */ if (expect_false (waittime < timeout_blocktime)) waittime = timeout_blocktime; - sleeptime = waittime - backend_fudge; + /* extra check because io_blocktime is commonly 0 */ + if (expect_false (io_blocktime)) + { + sleeptime = io_blocktime - (mn_now - prev_mn_now); - if (expect_true (sleeptime > io_blocktime)) - sleeptime = io_blocktime; + if (sleeptime > waittime - backend_fudge) + sleeptime = waittime - backend_fudge; - if (sleeptime) - { - ev_sleep (sleeptime); - waittime -= sleeptime; + if (expect_true (sleeptime > 0.)) + { + ev_sleep (sleeptime); + waittime -= sleeptime; + } } } |