changeset 66:568b4fd9ef61

common: add a relative timed condition wait wrapper Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Tue, 07 Jul 2015 21:42:02 -0400
parents a37c1adce732
children 903ff5d135a8
files src/common/include/nomad/mutex.h src/common/mutex.c
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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);
 
--- 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));