summaryrefslogtreecommitdiff
path: root/libddekit/condvar.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2012-11-25 23:12:41 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-11-25 23:12:41 +0100
commitd261675a592f6109826ccbdb07c7f485c4c88683 (patch)
tree4f739c11a9bec9ad1f2e9c8436fac7ee3e6dcf60 /libddekit/condvar.c
parente1b0e34210b385d05e50900486262709a9ee3a31 (diff)
Move DDE to pthreads
Diffstat (limited to 'libddekit/condvar.c')
-rw-r--r--libddekit/condvar.c24
1 files changed, 14 insertions, 10 deletions
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 <tf13@os.inf.tu-dresden.de>
*/
-#include <cthreads.h>
+#include <pthread.h>
+#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);
}