3 void flag_ini(Flag *flag)
6 pthread_cond_init(&flag->cnd, NULL);
7 pthread_mutex_init(&flag->mtx, NULL);
9 flag_sub(flag, &flag->cnd);
12 void flag_dst(Flag *flag)
14 pthread_cond_destroy(&flag->cnd);
15 pthread_mutex_destroy(&flag->mtx);
16 list_clr(&flag->cvs, NULL, NULL, NULL);
19 void flag_sub(Flag *flag, pthread_cond_t *cnd)
21 pthread_mutex_lock(&flag->mtx);
22 list_add(&flag->cvs, cnd, cnd, &cmp_ref, NULL);
23 pthread_mutex_unlock(&flag->mtx);
26 void flag_uns(Flag *flag, pthread_cond_t *cnd)
28 pthread_mutex_lock(&flag->mtx);
29 list_del(&flag->cvs, cnd, &cmp_ref, NULL, NULL, NULL);
30 pthread_mutex_unlock(&flag->mtx);
33 void flag_set(Flag *flag)
35 pthread_mutex_lock(&flag->mtx);
38 LIST_ITERATE(&flag->cvs, node)
39 pthread_cond_broadcast(node->dat);
41 pthread_mutex_unlock(&flag->mtx);
44 void flag_slp(Flag *flag)
46 pthread_mutex_lock(&flag->mtx);
48 pthread_cond_wait(&flag->cnd, &flag->mtx);
49 pthread_mutex_unlock(&flag->mtx);