FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bqueue.c
/*
 * Take the first element off of q.  If there are no elements on the queue, wait
 * until one is put there.  Return the removed element.
 */
Take the first element off of q.  If there are no elements on the queue, wait
until one is put there.  Return the removed element.
Take the first element off of q . If there are no elements on the queue wait until one is put there . Return the removed element .
void *
bqueue_dequeue(bqueue_t *q)
{
	void *ret;
	uint64_t item_size;
	mutex_enter(&q->bq_lock);
	while (q->bq_size == 0) {
		cv_wait(&q->bq_pop_cv, &q->bq_lock);
	}
	ret = list_remove_head(&q->bq_list);
	item_size = obj2node(q, ret)->bqn_size;
	q->bq_size -= item_size;
	mutex_exit(&q->bq_lock);
	cv_signal(&q->bq_add_cv);
	return (ret);
}
void * bqueue_dequeue ( bqueue_t * q ) { void * ret ; uint64_t item_size ; mutex_enter ( & q -> bq_lock ) ; while ( q -> bq_size == 0 ) { cv_wait ( & q -> bq_pop_cv , & q -> bq_lock ) ; } ret = list_remove_head ( & q -> bq_list ) ; item_size = obj2node ( q , ret ) -> bqn_size ; q -> bq_size -= item_size ; mutex_exit ( & q -> bq_lock ) ; cv_signal ( & q -> bq_add_cv ) ; return ( ret ) ; }
Take the first element off of q.
Take the first element off of q .