+
+ void *data = item ? item->data : NULL;
+ free(item);
+ return data;
+}
+
+static inline __attribute__((__warn_unused_result__)) void *meshlink_queue_pop_cond(meshlink_queue_t *queue, pthread_cond_t *cond) {
+ meshlink_queue_item_t *item;
+
+ pthread_mutex_lock(&queue->mutex);
+
+ while(!queue->head) {
+ pthread_cond_wait(cond, &queue->mutex);
+ }
+
+ item = queue->head;
+ queue->head = item->next;
+
+ if(!queue->head) {
+ queue->tail = NULL;
+ }
+
+ pthread_mutex_unlock(&queue->mutex);
+
+ void *data = item->data;