mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 18:45:10 +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:
parent
8bb6b479a8
commit
6769495e10
@ -3,7 +3,8 @@
|
|||||||
2008-09-11
|
2008-09-11
|
||||||
* Maybe fix missing include bug
|
* Maybe fix missing include bug
|
||||||
(http://bugs.gentoo.org/show_bug.cgi?id=235233)
|
(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
|
2008-09-10
|
||||||
* Improved hddtemp support
|
* Improved hddtemp support
|
||||||
|
18
src/conky.c
18
src/conky.c
@ -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)
|
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;
|
last_update_time = current_update_time;
|
||||||
total_updates++;
|
total_updates++;
|
||||||
// free(p);
|
// free(p);
|
||||||
@ -7355,6 +7361,7 @@ static void main_loop(void)
|
|||||||
#ifdef SIGNAL_BLOCKING
|
#ifdef SIGNAL_BLOCKING
|
||||||
sigset_t newmask, oldmask;
|
sigset_t newmask, oldmask;
|
||||||
#endif
|
#endif
|
||||||
|
double t;
|
||||||
#ifdef X11
|
#ifdef X11
|
||||||
Region region = XCreateRegion();
|
Region region = XCreateRegion();
|
||||||
|
|
||||||
@ -7379,6 +7386,7 @@ static void main_loop(void)
|
|||||||
sigaddset(&newmask, SIGUSR1);
|
sigaddset(&newmask, SIGUSR1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
next_update_time = last_update_time = get_time();
|
||||||
info.looped = 0;
|
info.looped = 0;
|
||||||
while (total_run_times == 0 || info.looped < total_run_times) {
|
while (total_run_times == 0 || info.looped < total_run_times) {
|
||||||
info.looped++;
|
info.looped++;
|
||||||
@ -7399,10 +7407,12 @@ static void main_loop(void)
|
|||||||
fd_set fdsr;
|
fd_set fdsr;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int s;
|
int s;
|
||||||
double t = update_interval - (get_time() - last_update_time);
|
t = next_update_time - get_time();
|
||||||
|
|
||||||
if (t < 0) {
|
if (t < 0) {
|
||||||
t = 0;
|
t = 0;
|
||||||
|
} else if (t > update_interval) {
|
||||||
|
t = update_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
tv.tv_sec = (long) t;
|
tv.tv_sec = (long) t;
|
||||||
@ -7419,8 +7429,8 @@ static void main_loop(void)
|
|||||||
/* timeout */
|
/* timeout */
|
||||||
if (s == 0) {
|
if (s == 0) {
|
||||||
#else
|
#else
|
||||||
/* FIXME just sleep for the interval time if no X11 */
|
t = (next_update_time - get_time()) * 1000000;
|
||||||
usleep(update_interval * 1000000);
|
usleep((useconds_t)t);
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
update_text();
|
update_text();
|
||||||
#ifdef X11
|
#ifdef X11
|
||||||
|
@ -208,6 +208,11 @@ int timed_thread_test(timed_thread *p_timed_thread)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rc == 0) {
|
||||||
|
/* runnable_cond was signaled, so tell caller to exit thread */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* absolute future time for next pass */
|
/* 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_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->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;
|
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 */
|
/* tell caller not to exit yet */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user