c/thread/cnd timedwait

Atomically unlocks the mutex pointed to by and blocks on the condition variable pointed to by  until the thread is signalled by cnd_signal or cnd_broadcast, or until the  based time point pointed to by  has been reached, or until a spurious wake-up occurs. The mutex is locked again before the function returns.

The behavior is undefined if the mutex is not already locked by the calling thread.

Return value
thrd_success if successful, if the timeout time has been reached before the mutex is locked, or  thrd_error if an error occurred.