Support to multi-threading and pthread interface (POSIX.1-2008) (#23)
[lunaix-os.git] / lunaix-os / includes / lunaix / ds / waitq.h
1 #ifndef __LUNAIX_CODVAR_H
2 #define __LUNAIX_CODVAR_H
3
4 #include <lunaix/ds/llist.h>
5
6 typedef struct waitq
7 {
8     struct llist_header waiters;
9 } waitq_t;
10
11 static inline void
12 waitq_init(waitq_t* waitq)
13 {
14     llist_init_head(&waitq->waiters);
15 }
16
17 static inline int
18 waitq_empty(waitq_t* waitq)
19 {
20     return llist_empty(&waitq->waiters);
21 }
22
23 static inline void
24 waitq_cancel_wait(waitq_t* waitq)
25 {
26     llist_delete(&waitq->waiters);
27 }
28
29 void
30 pwait(waitq_t* queue);
31
32 void
33 pwake_one(waitq_t* queue);
34
35 void
36 pwake_all(waitq_t* queue);
37
38 #endif /* __LUNAIX_CODVAR_H */