c++ - pthread_cond_timedwait return ETIMEDOUT before real timeout in Android -


i use pthread_cond_timewait block thread given time or make waiting signal in andorid native c++ code, below wait function. in android o, wait function may return etimedout early, before timeout. not understand why happens.

int wait(mutexlock& mutex, int64_t misc) {     int iret=-1;      if(misc<=0)     {         iret = pthread_cond_wait(&cond_, &mutex.get_pthread_mutex());         return iret;     }     struct timespec ts;     timeval now;      gettimeofday(&now,null);     ts.tv_sec = now.tv_sec;     ts.tv_nsec = now.tv_usec * 1000;     ts.tv_sec +=misc/1000;     uint64_t cur_misc=ts.tv_nsec/1000000;     uint64_t tmp_misc=cur_misc+misc%1000;     ts.tv_sec +=tmp_misc/1000;     ts.tv_nsec =(tmp_misc%1000)*1000000;        iret=pthread_cond_timedwait(&cond_, &mutex.get_pthread_mutex(), &ts);     return iret; } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -