在C11中,
cnd_timedwait
函数的定义如下:
当出现虚假唤醒时,该函数会返回还是?尽管据我所知,虚假唤醒在技术上并不被视为错误。int cnd_timedwait( cnd_t* restrict cond, mtx_t* restrict mutex, const struct timespec* restrict time_point );
Atomically unlocks the mutex pointed to by mutex and blocks on the condition variable pointed to by cond until the thread is signalled by
cnd_signal
orcnd_broadcast
, or until theTIME_UTC
based time point pointed to by time_point has been reached, or until a spurious wake-up occurs. The mutex is locked again before the function returns.Return value
thrd_success
if successful,thrd_timedout
if the timeout time has been reached before the mutex is locked, orthrd_error
if an error occurred.