From d261675a592f6109826ccbdb07c7f485c4c88683 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 25 Nov 2012 23:12:41 +0100 Subject: Move DDE to pthreads --- libddekit/condvar.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'libddekit/condvar.c') diff --git a/libddekit/condvar.c b/libddekit/condvar.c index 55c57f8b..64df3ed6 100644 --- a/libddekit/condvar.c +++ b/libddekit/condvar.c @@ -4,31 +4,35 @@ * * \author Thomas Friebel */ -#include +#include +#include "ddekit/memory.h" #include "ddekit/condvar.h" struct ddekit_condvar { - struct condition cond; + pthread_cond_t cond; }; ddekit_condvar_t *ddekit_condvar_init() { - struct condition *cvp; + ddekit_condvar_t *cvp; - cvp = condition_alloc (); - condition_init (cvp); + cvp = ddekit_simple_malloc (sizeof (*cvp)); - return (ddekit_condvar_t *) cvp; + if (cvp == NULL) + return NULL; + + pthread_cond_init (&cvp->cond, NULL); + return cvp; } void ddekit_condvar_deinit(ddekit_condvar_t *cvp) { - condition_free (&cvp->cond); + ddekit_simple_free (cvp); } void ddekit_condvar_wait(ddekit_condvar_t *cvp, ddekit_lock_t *mp) { /* This isn't nice. The encapsulation is broken. * TODO I can merge the two files condvar.c and lock.c. */ - condition_wait (&cvp->cond, (struct mutex *) *mp); + pthread_cond_wait (&cvp->cond, (pthread_mutex_t *) *mp); } int ddekit_condvar_wait_timed(ddekit_condvar_t *cvp, @@ -40,9 +44,9 @@ int ddekit_condvar_wait_timed(ddekit_condvar_t *cvp, void ddekit_condvar_signal(ddekit_condvar_t *cvp) { - condition_signal (&cvp->cond); + pthread_cond_signal (&cvp->cond); } void ddekit_condvar_broadcast(ddekit_condvar_t *cvp) { - condition_broadcast (&cvp->cond); + pthread_cond_broadcast (&cvp->cond); } -- cgit v1.2.3