MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pthread_cond_timedwait

Function pthread_cond_timedwait

components/libc/posix/pthreads/pthread_cond.c:530–549  ·  view source on GitHub ↗

* @brief Waits on a condition variable with a timeout. * * This function blocks the calling thread on the condition variable `cond`, releasing * the associated mutex `mutex`. The thread remains blocked until one of the following occurs: * - The condition variable is signaled or broadcast using `pthread_cond_signal` or `pthread_cond_broadcast`. * - The specified absolute timeout `abstime` is r

Source from the content-addressed store, hash-verified

528 * @see pthread_cond_wait, pthread_cond_signal, pthread_cond_broadcast, pthread_mutex_lock
529 */
530int pthread_cond_timedwait(pthread_cond_t *cond,
531 pthread_mutex_t *mutex,
532 const struct timespec *abstime)
533{
534 int timeout;
535 rt_err_t result;
536
537 timeout = rt_timespec_to_tick(abstime);
538 result = _pthread_cond_timedwait(cond, mutex, timeout);
539 if (result == RT_EOK)
540 {
541 return 0;
542 }
543 if (result == -RT_ETIMEOUT)
544 {
545 return ETIMEDOUT;
546 }
547
548 return EINVAL;
549}
550RTM_EXPORT(pthread_cond_timedwait);

Callers 3

test_threadFunction · 0.85

Calls 2

rt_timespec_to_tickFunction · 0.85
_pthread_cond_timedwaitFunction · 0.85

Tested by 1

test_threadFunction · 0.68