Lines Matching refs:b
41 uv_barrier_t* b; in uv_barrier_init() local
42 b = barrier; in uv_barrier_init()
47 struct _uv_barrier* b; in uv_barrier_init() local
52 b = uv__malloc(sizeof(*b)); in uv_barrier_init()
53 if (b == NULL) in uv_barrier_init()
57 b->in = 0; in uv_barrier_init()
58 b->out = 0; in uv_barrier_init()
59 b->threshold = count; in uv_barrier_init()
61 rc = uv_mutex_init(&b->mutex); in uv_barrier_init()
66 rc = uv_cond_init((uv_cond_t*) &b->cond); in uv_barrier_init()
71 barrier->b = b; in uv_barrier_init()
76 uv_mutex_destroy(&b->mutex); in uv_barrier_init()
79 uv__free(b); in uv_barrier_init()
88 uv_barrier_t* b; in uv_barrier_wait() local
89 b = barrier; in uv_barrier_wait()
91 struct _uv_barrier* b; in uv_barrier_wait() local
93 if (barrier == NULL || barrier->b == NULL) in uv_barrier_wait()
96 b = barrier->b; in uv_barrier_wait()
99 uv_mutex_lock(&b->mutex); in uv_barrier_wait()
101 while (b->out != 0) in uv_barrier_wait()
102 uv_cond_wait((uv_cond_t*) &b->cond, &b->mutex); in uv_barrier_wait()
104 if (++b->in == b->threshold) { in uv_barrier_wait()
105 b->in = 0; in uv_barrier_wait()
106 b->out = b->threshold; in uv_barrier_wait()
107 uv_cond_broadcast((uv_cond_t*) &b->cond); in uv_barrier_wait()
110 uv_cond_wait((uv_cond_t*) &b->cond, &b->mutex); in uv_barrier_wait()
111 while (b->in != 0); in uv_barrier_wait()
114 last = (--b->out == 0); in uv_barrier_wait()
116 uv_cond_broadcast((uv_cond_t*) &b->cond); in uv_barrier_wait()
118 uv_mutex_unlock(&b->mutex); in uv_barrier_wait()
125 uv_barrier_t* b; in uv_barrier_destroy() local
126 b = barrier; in uv_barrier_destroy()
128 struct _uv_barrier* b; in uv_barrier_destroy()
129 b = barrier->b; in uv_barrier_destroy()
132 uv_mutex_lock(&b->mutex); in uv_barrier_destroy()
134 assert(b->in == 0); in uv_barrier_destroy()
135 while (b->out != 0) in uv_barrier_destroy()
136 uv_cond_wait((uv_cond_t*) &b->cond, &b->mutex); in uv_barrier_destroy()
138 if (b->in != 0) in uv_barrier_destroy()
141 uv_mutex_unlock(&b->mutex); in uv_barrier_destroy()
142 uv_mutex_destroy(&b->mutex); in uv_barrier_destroy()
143 uv_cond_destroy((uv_cond_t*) &b->cond); in uv_barrier_destroy()
146 uv__free(barrier->b); in uv_barrier_destroy()
147 barrier->b = NULL; in uv_barrier_destroy()