0
等待狀態變量在linux等待條件變量時會發生什麼情況時condition_timed_wiat()時間逝去時會發生什麼情況時condition_timed_wiat時間流逝在linux
struct timeval tv;
struct timespec ts;
gettimeofday(&tv, NULL);
ts.tv_sec = time(NULL) + timeInMs/1000;
ts.tv_nsec = tv.tv_usec * 1000 + 1000 * 1000 * (timeInMs % 1000);
ts.tv_sec += ts.tv_nsec/(1000 * 1000 * 1000);
ts.tv_nsec %= (1000 * 1000 * 1000);
n = pthread_cond_timedwait(&condition, &mutex, &ts);