* @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
| 528 | * @see pthread_cond_wait, pthread_cond_signal, pthread_cond_broadcast, pthread_mutex_lock |
| 529 | */ |
| 530 | int 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 | } |
| 550 | RTM_EXPORT(pthread_cond_timedwait); |