This source file includes following definitions.
- glthread_cond_init
- glthread_cond_wait
- glthread_cond_timedwait
- glthread_cond_signal
- glthread_cond_broadcast
- glthread_cond_destroy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <config.h>
21
22 #define _GLTHREAD_COND_INLINE _GL_EXTERN_INLINE
23 #include "glthread/cond.h"
24
25
26
27 #if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS
28
29 int
30 glthread_cond_init (gl_cond_t *condition)
31 {
32 if (cnd_init (&condition->condition) != thrd_success)
33 return ENOMEM;
34 condition->init_needed = 0;
35 return 0;
36 }
37
38 int
39 glthread_cond_wait (gl_cond_t *condition, gl_lock_t *lock)
40 {
41 if (condition->init_needed)
42 call_once (&condition->init_once, condition->init_func);
43 if (lock->init_needed)
44 call_once (&lock->init_once, lock->init_func);
45 if (cnd_wait (&condition->condition, &lock->mutex) != thrd_success)
46 return EINVAL;
47 return 0;
48 }
49
50 int
51 glthread_cond_timedwait (gl_cond_t *condition, gl_lock_t *lock,
52 const struct timespec *abstime)
53 {
54 if (condition->init_needed)
55 call_once (&condition->init_once, condition->init_func);
56 if (lock->init_needed)
57 call_once (&lock->init_once, lock->init_func);
58 switch (cnd_timedwait (&condition->condition, &lock->mutex, abstime))
59 {
60 case thrd_success:
61 break;
62 case thrd_timedout:
63 return ETIMEDOUT;
64 default:
65 return EINVAL;
66 }
67 return 0;
68 }
69
70 int
71 glthread_cond_signal (gl_cond_t *condition)
72 {
73 if (condition->init_needed)
74 call_once (&condition->init_once, condition->init_func);
75 if (cnd_signal (&condition->condition) != thrd_success)
76 return EINVAL;
77 return 0;
78 }
79
80 int
81 glthread_cond_broadcast (gl_cond_t *condition)
82 {
83 if (condition->init_needed)
84 call_once (&condition->init_once, condition->init_func);
85 if (cnd_broadcast (&condition->condition) != thrd_success)
86 return EINVAL;
87 return 0;
88 }
89
90 int
91 glthread_cond_destroy (gl_cond_t *condition)
92 {
93 if (condition->init_needed)
94 call_once (&condition->init_once, condition->init_func);
95 cnd_destroy (&condition->condition);
96 return 0;
97 }
98
99 #endif
100
101
102
103 #if USE_POSIX_THREADS
104
105 #endif
106
107
108
109 #if USE_WINDOWS_THREADS
110
111 #endif
112
113