i'm sorry for my pool english.the question is like this:
in funciton cq_init, initialize a condition (cq->cond).
static void cq_init(CQ *cq) {
pthread_mutex_init(&cq->lock, NULL);
pthread_cond_init(&cq->cond, NULL); //this line
cq->head = NULL;
cq->tail = NULL;
}
when a connection from client come in, the listen thread dispath the
task, and call cq_push,
static void cq_push(CQ *cq, CQ_ITEM *item) {
item->next = NULL;
pthread_mutex_lock(&cq->lock);
if (NULL == cq->tail)
cq->head = item;
else
cq->tail->next = item;
cq->tail = item;
pthread_cond_signal(&cq->cond); //this line
pthread_mutex_unlock(&cq->lock);
}
but i not found the task thread call pthread_cond_wait(&cq->cond);
what the cq->cond for?
thanks