void sleepms_on_cond(pthread_cond_t *cond, pthread_mutex_t *mutex, uint32_t msec) { struct timespec ts; add_ms_to_timespec(&ts, msec); pthread_mutex_lock(mutex); pthread_cond_timedwait(cond, mutex, &ts); // sleep on sleep_cond pthread_mutex_unlock(mutex); }
void sleepms_on_cond(const char *n, pthread_mutex_t *mutex, pthread_cond_t *cond, uint32_t msec) { struct timespec ts; add_ms_to_timespec(&ts, msec); SAFE_MUTEX_LOCK_R(mutex, n); SAFE_COND_TIMEDWAIT_R(cond, mutex, &ts, n); // sleep on sleep_cond SAFE_MUTEX_UNLOCK_R(mutex, n); }