blob: 55c57f8b5b9ecf769673864001ee1717256ffa2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/**
* Unchecked (no BSD invariants) condition variable implementation for
* dde-internal use. Written from scratch.
*
* \author Thomas Friebel <tf13@os.inf.tu-dresden.de>
*/
#include <cthreads.h>
#include "ddekit/condvar.h"
struct ddekit_condvar {
struct condition cond;
};
ddekit_condvar_t *ddekit_condvar_init() {
struct condition *cvp;
cvp = condition_alloc ();
condition_init (cvp);
return (ddekit_condvar_t *) cvp;
}
void ddekit_condvar_deinit(ddekit_condvar_t *cvp) {
condition_free (&cvp->cond);
}
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);
}
int ddekit_condvar_wait_timed(ddekit_condvar_t *cvp,
ddekit_lock_t *mp, int timo) {
// TODO currently just let it like this.
ddekit_condvar_wait (cvp, mp);
return 0;
}
void ddekit_condvar_signal(ddekit_condvar_t *cvp)
{
condition_signal (&cvp->cond);
}
void ddekit_condvar_broadcast(ddekit_condvar_t *cvp) {
condition_broadcast (&cvp->cond);
}
|