5 #include <simgear/compiler.h>
8 #include "SGThread.hxx"
11 start_handler( void* arg )
13 SGThread* thr = static_cast<SGThread*>(arg);
21 int status = pthread_mutex_lock( &mutex );
26 assert( status == 0 );
31 SGCondition::wait( SGMutex& mutex, unsigned long ms )
34 ::gettimeofday( &now, 0 );
36 // Wait time is now + ms milliseconds
37 unsigned int sec = ms / 1000;
38 unsigned int nsec = (ms % 1000) * 1000;
39 struct timespec abstime;
40 abstime.tv_sec = now.tv_sec + sec;
41 abstime.tv_nsec = now.tv_usec*1000 + nsec;
43 int status = pthread_cond_timedwait( &cond, &mutex.mutex, &abstime );
44 if (status == ETIMEDOUT)
49 assert( status == 0 );