14 #include "../mythreads.h"
26 struct UpdateThreadData
29 volatile bool shutdown;
38 static UpdateThreadData S_updateThreadData;
40 static void* PerformUpdateThreadWorkerFunction(
void* pThreadData )
42 const UpdateThreadData* pUpdateThreadData = (UpdateThreadData*)pThreadData;
46 while( !error && !pUpdateThreadData->shutdown ) {
49 FunctionResult fr = pUpdateThreadData->pUpdateModule->performUpdate(force, results);
56 for (
size_t k=0; k<60 && !pUpdateThreadData->shutdown; ++k)
65 static pthread_t S_hUpdateThread = 0;
69 S_updateThreadData.pUpdateModule = &aUpdateModule;
71 pthread_create(&S_hUpdateThread , NULL, PerformUpdateThreadWorkerFunction, (
void*)&S_updateThreadData);
76 S_updateThreadData.shutdown =
true;
77 pthread_join(S_hUpdateThread, NULL);
80 void mySleep(
unsigned nTimeMs )
83 sleeptime.tv_sec = nTimeMs / 1000;
84 sleeptime.tv_nsec = 1000*1000*(nTimeMs % 1000);
88 while( nanosleep( &sleeptime, &remaintime ) == -1 )
90 int tmp_errno = errno;
91 if( tmp_errno != EINTR ) {
96 sleeptime.tv_sec = remaintime.tv_sec;
97 sleeptime.tv_nsec = remaintime.tv_nsec;