2008-09-11
* Maybe fix missing include bug
(http://bugs.gentoo.org/show_bug.cgi?id=235233)
- * Improve timed_thread timing
+ * Improve timed_thread interval timing
+ * Improve Conky's overall interval timing
2008-09-10
* Improved hddtemp support
}
}
-double current_update_time, last_update_time;
+double current_update_time, next_update_time, last_update_time;
static void generate_text(void)
{
}
}
+ next_update_time += update_interval;
+ if (next_update_time < get_time()) {
+ next_update_time = get_time() + update_interval;
+ } else if (next_update_time > get_time() + update_interval) {
+ next_update_time = get_time() + update_interval;
+ }
last_update_time = current_update_time;
total_updates++;
// free(p);
#ifdef SIGNAL_BLOCKING
sigset_t newmask, oldmask;
#endif
+ double t;
#ifdef X11
Region region = XCreateRegion();
sigaddset(&newmask, SIGUSR1);
#endif
+ next_update_time = last_update_time = get_time();
info.looped = 0;
while (total_run_times == 0 || info.looped < total_run_times) {
info.looped++;
fd_set fdsr;
struct timeval tv;
int s;
- double t = update_interval - (get_time() - last_update_time);
+ t = next_update_time - get_time();
if (t < 0) {
t = 0;
+ } else if (t > update_interval) {
+ t = update_interval;
}
tv.tv_sec = (long) t;
/* timeout */
if (s == 0) {
#else
- /* FIXME just sleep for the interval time if no X11 */
- usleep(update_interval * 1000000);
+ t = (next_update_time - get_time()) * 1000000;
+ usleep((useconds_t)t);
#endif /* X11 */
update_text();
#ifdef X11
return -1;
}
+ if (rc == 0) {
+ /* runnable_cond was signaled, so tell caller to exit thread */
+ return 1;
+ }
+
/* absolute future time for next pass */
p_timed_thread->wait_time.tv_sec += p_timed_thread->interval_time.tv_sec;
p_timed_thread->wait_time.tv_nsec += p_timed_thread->interval_time.tv_nsec;
p_timed_thread->wait_time.tv_nsec = p_timed_thread->wait_time.tv_nsec % 1000000000;
}
- if (rc == 0) {
- /* runnable_cond was signaled, so tell caller to exit thread */
- return 1;
- }
-
/* tell caller not to exit yet */
return 0;
}