1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 04:06:03 +00:00
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@524 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2006-02-02 02:23:18 +00:00
parent d7635e7c1b
commit 9d54a08e65

View File

@ -1032,6 +1032,8 @@ void lock_all_threads()
ret = pthread_mutex_lock(&(thread_list[i]->mutex)); ret = pthread_mutex_lock(&(thread_list[i]->mutex));
if (ret) { if (ret) {
ERR("giving up on thread %i", (int)thread_list[i]->thread); ERR("giving up on thread %i", (int)thread_list[i]->thread);
} else {
ERR("locked %i of %i", i+1, thread_count);
} }
} }
} }
@ -1048,10 +1050,11 @@ void replace_thread(struct thread_info_s *new_thread, int pos) // this isn't eve
void *threaded_exec(struct text_object *obj) { // pthreads are really beginning to piss me off void *threaded_exec(struct text_object *obj) { // pthreads are really beginning to piss me off
double update_time; double update_time;
int unlock;
while (1) { while (1) {
update_time = get_time(); update_time = get_time();
if (pthread_mutex_trylock(&(obj->data.execi.thread_info.mutex))) { if (pthread_mutex_trylock(&(obj->data.execi.thread_info.mutex))) {
break; pthread_exit(NULL);
} }
char *p2 = obj->data.execi.buffer; char *p2 = obj->data.execi.buffer;
FILE *fp = popen(obj->data.execi.cmd,"r"); FILE *fp = popen(obj->data.execi.cmd,"r");
@ -1066,15 +1069,24 @@ void *threaded_exec(struct text_object *obj) { // pthreads are really beginning
p2++; p2++;
} }
obj->data.execi.last_update = update_time; obj->data.execi.last_update = update_time;
usleep(100); // prevent race condition unlock = pthread_mutex_unlock(&(obj->data.execi.thread_info.mutex));
int unlock = pthread_mutex_unlock(&(obj->data.execi.thread_info.mutex));
if (unlock) { if (unlock) {
ERR("error %i unlocking thread", unlock); ERR("error %i unlocking thread", unlock);
pthread_exit(NULL);
}
usleep(100); // prevent race condition
if (pthread_mutex_trylock(&(obj->data.execi.thread_info.mutex))) {
pthread_exit(NULL);
}
unlock = pthread_mutex_unlock(&(obj->data.execi.thread_info.mutex));
if (unlock) {
ERR("error %i unlocking thread", unlock);
pthread_exit(NULL);
} }
if (get_time() - obj->data.execi.last_update > obj->data.execi.interval) { if (get_time() - obj->data.execi.last_update > obj->data.execi.interval) {
continue; continue;
} else { } else {
unsigned int delay = 1000000 * (obj->data.execi.interval -(get_time() - obj->data.execi.last_update)); unsigned int delay = 1000000.0 * (obj->data.execi.interval -(get_time() - obj->data.execi.last_update));
if (delay < update_interval * 500000) { if (delay < update_interval * 500000) {
delay = update_interval * 1000000; delay = update_interval * 1000000;
} }