diff options
Diffstat (limited to 'locks/unix/thread_cond.c')
-rw-r--r-- | locks/unix/thread_cond.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/locks/unix/thread_cond.c b/locks/unix/thread_cond.c index 3c7ad6fa7..0a107569a 100644 --- a/locks/unix/thread_cond.c +++ b/locks/unix/thread_cond.c @@ -124,6 +124,31 @@ APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, return stat; } +APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, + apr_thread_mutex_t *mutex, + apr_interval_time_t timeout) +{ + apr_status_t stat; + apr_time_t then; + struct timespec abstime; + + then = apr_time_now() + timeout; + abstime.tv_sec = then / APR_USEC_PER_SEC; + abstime.tv_nsec = (then % APR_USEC_PER_SEC) * 1000; /* nanoseconds */ + + stat = pthread_cond_timedwait(cond->cond, &mutex->mutex, &abstime); +#ifdef PTHREAD_SETS_ERRNO + if (stat) { + stat = errno; + } +#endif + if (ETIMEDOUT == stat) { + return APR_TIMEUP; + } + return stat; +} + + APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) { apr_status_t stat; |