1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 21:49:07 +00:00

* Improve Conky's overall interval timing

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1250 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2008-09-12 03:01:33 +00:00
parent 8bb6b479a8
commit 6769495e10
3 changed files with 21 additions and 10 deletions

View File

@ -3,7 +3,8 @@
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

View File

@ -6379,7 +6379,7 @@ head:
}
}
double current_update_time, last_update_time;
double current_update_time, next_update_time, last_update_time;
static void generate_text(void)
{
@ -6416,6 +6416,12 @@ 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);
@ -7355,6 +7361,7 @@ static void main_loop(void)
#ifdef SIGNAL_BLOCKING
sigset_t newmask, oldmask;
#endif
double t;
#ifdef X11
Region region = XCreateRegion();
@ -7379,6 +7386,7 @@ static void main_loop(void)
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++;
@ -7399,10 +7407,12 @@ static void main_loop(void)
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;
@ -7419,8 +7429,8 @@ static void main_loop(void)
/* 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

View File

@ -208,6 +208,11 @@ int timed_thread_test(timed_thread *p_timed_thread)
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;
@ -222,11 +227,6 @@ int timed_thread_test(timed_thread *p_timed_thread)
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;
}