%HAXELIB_ROOT%/hxcpp/4,2,1/include/hx/Thread.h
// Returns true if the wait was success, false on timeout.
Returns true if the wait was success, false on timeout.
Returns true if the wait was success false on timeout .
bool WaitSeconds(double inSeconds)
   {
      struct timeval tv;
      gettimeofday(&tv, 0);
      int isec = (int)inSeconds;
      int usec = (int)((inSeconds-isec)*1000000.0);
      timespec spec;
      spec.tv_nsec = (tv.tv_usec + usec) * 1000;
      if (spec.tv_nsec>1000000000)
      {
         spec.tv_nsec-=1000000000;
         isec++;
      }
      spec.tv_sec = tv.tv_sec + isec;
      AutoLock lock(mMutex);
      int result = 0;
      while( !mSet &&  (result=pthread_cond_timedwait( &mCondition, &mMutex.mMutex, &spec )) != ETIMEDOUT)
      {
         if (result!=0)
         {
            break;
         }
      }
      bool wasSet = mSet;
      mSet = false;
      return wasSet;
   }
bool WaitSeconds ( double inSeconds ) { struct timeval tv ; gettimeofday ( & tv , 0 ) ; int isec = ( int ) inSeconds ; int usec = ( int ) ( ( inSeconds - isec ) * 1000000.0 ) ; timespec spec ; spec . tv_nsec = ( tv . tv_usec + usec ) * 1000 ; if ( spec . tv_nsec > 1000000000 ) { spec . tv_nsec -= 1000000000 ; isec ++ ; } spec . tv_sec = tv . tv_sec + isec ; AutoLock lock ( mMutex ) ; int result = 0 ; while ( ! mSet && ( result = pthread_cond_timedwait ( & mCondition , & mMutex . mMutex , & spec ) ) != ETIMEDOUT ) { if ( result != 0 ) { break ; } } bool wasSet = mSet ; mSet = false ; return wasSet ; }
Returns true if the wait was success, false on timeout.
Returns true if the wait was success false on timeout .
// Wait for set to be true... // Error - something's gone wrong... /*
            if (result==EINVAL) 
               printf("ERROR: Condition EINVAL\n");
            else if (result==EPERM)
               printf("ERROR: Condition EPERM\n");
            else
               printf("ERROR: Condition unknown error\n");
            */ // Condition signalled - but try mSet again ...