Fix previous commit by saving file;
This commit is contained in:
parent
ddddeebc59
commit
3cb0883b4a
1 changed files with 20 additions and 0 deletions
20
mq.c
20
mq.c
|
@ -105,3 +105,23 @@ haggis_msg* haggis_mq_pop(haggis_mq *queue) {
|
|||
msg->prev = msg->next = NULL;
|
||||
return msg;
|
||||
}
|
||||
|
||||
haggis_msg* haggis_mq_try_pop(haggis_mq *queue) {
|
||||
haggis_msg *msg;
|
||||
|
||||
if (queue->count == 0)
|
||||
return NULL;
|
||||
pthread_mutex_lock(&queue->mutex);
|
||||
queue->count--;
|
||||
msg = queue->head;
|
||||
if (msg->tag == EndOfArchive)
|
||||
return msg;
|
||||
if (queue->tail == queue->head) {
|
||||
queue->tail = queue->head = NULL;
|
||||
} else {
|
||||
queue->head = queue->head->prev;
|
||||
}
|
||||
pthread_mutex_unlock(&queue->mutex);
|
||||
msg->prev = msg->next = NULL;
|
||||
return msg;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue