# HG changeset patch # User Josef 'Jeff' Sipek # Date 1436319722 14400 # Node ID 568b4fd9ef618591f1789be7027b9f89c8f43c28 # Parent a37c1adce732344e2dbb77271f9bffd9b35c5513 common: add a relative timed condition wait wrapper Signed-off-by: Josef 'Jeff' Sipek diff -r a37c1adce732 -r 568b4fd9ef61 src/common/include/nomad/mutex.h --- a/src/common/include/nomad/mutex.h Tue Jul 07 21:41:30 2015 -0400 +++ b/src/common/include/nomad/mutex.h Tue Jul 07 21:42:02 2015 -0400 @@ -39,6 +39,8 @@ extern void condinit(pthread_cond_t *c); extern void conddestroy(pthread_cond_t *c); extern void condwait(pthread_cond_t *c, pthread_mutex_t *m); +extern int condreltimedwait(pthread_cond_t *c, pthread_mutex_t *m, + const struct timespec *reltime); extern void condsig(pthread_cond_t *c); extern void condbcast(pthread_cond_t *c); diff -r a37c1adce732 -r 568b4fd9ef61 src/common/mutex.c --- a/src/common/mutex.c Tue Jul 07 21:41:30 2015 -0400 +++ b/src/common/mutex.c Tue Jul 07 21:42:02 2015 -0400 @@ -84,6 +84,19 @@ VERIFY0(pthread_cond_wait(c, m)); } +int condreltimedwait(pthread_cond_t *c, pthread_mutex_t *m, + const struct timespec *reltime) +{ + int ret; + + ret = pthread_cond_reltimedwait_np(c, m, reltime); + + if ((ret != 0) || (ret != ETIMEDOUT)) + VERIFY(0); + + return ret; +} + void condsig(pthread_cond_t *c) { VERIFY0(pthread_cond_signal(c));