struct timespec ts;
int rc;
clock_gettime(CLOCK_MONOTONIC, &ts);
ts.tv_nsec += 300000000;//tv_nsec的最大值是999999999,这里直接加300毫秒,大概率会溢出,如果溢出应该把ts.tv_sec加1。
pthread_mutex_lock(&mutex_data_);
while(true){
rc = pthread_cond_timedwait(&cond_data_,&mutex_data_,&ts);
if(rc ==0)
break;
else{
BC_WARNING << "pthread_cond_timedwait err:" << strerror(errno);
if(errno != EINTR)
break;
}
}