From: <pk...@us...> - 2007-09-01 21:08:02
|
Revision: 948 http://conky.svn.sourceforge.net/conky/?rev=948&view=rev Author: pkovacs Date: 2007-09-01 14:07:40 -0700 (Sat, 01 Sep 2007) Log Message: ----------- timed thread work Modified Paths: -------------- trunk/conky1/src/timed_thread.c Modified: trunk/conky1/src/timed_thread.c =================================================================== --- trunk/conky1/src/timed_thread.c 2007-09-01 20:40:34 UTC (rev 947) +++ trunk/conky1/src/timed_thread.c 2007-09-01 21:07:40 UTC (rev 948) @@ -179,10 +179,21 @@ int timed_thread_test (timed_thread* p_timed_thread) { + struct timespec nowtime; int rc; assert (p_timed_thread != NULL); + /* adjust wait time to now if absolute_time drifted behind */ + now (&nowtime); + if ( ((nowtime.tv_sec * 1000000000) + nowtime.tv_nsec) > + ((p_timed_thread->absolute_time.tv_sec * 1000000000) + p_timed_thread->absolute_time.tv_nsec) ) + { + p_timed_thread->absolute_time.tv_sec = nowtime.tv_sec; + p_timed_thread->absolute_time.tv_nsec = nowtime.tv_nsec; + } + + /* acquire runnable_cond mutex */ if (pthread_mutex_lock (&p_timed_thread->runnable_mutex)) return (-1); /* could not acquire runnable_cond mutex, so tell caller to exit thread */ @@ -194,9 +205,7 @@ /* mutex re-acquired, so release it */ pthread_mutex_unlock (&p_timed_thread->runnable_mutex); - /* timestamp absolute future time for next pass */ - if (now (&p_timed_thread->absolute_time)) - return (-1); + /* absolute future time for next pass */ p_timed_thread->absolute_time.tv_sec += p_timed_thread->interval_time.tv_sec; p_timed_thread->absolute_time.tv_nsec += p_timed_thread->interval_time.tv_nsec; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |