FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bqueue.c
/*
 * Initialize a blocking queue  The maximum capacity of the queue is set to
 * size.  Types that want to be stored in a bqueue must contain a bqueue_node_t,
 * and offset should give its offset from the start of the struct.  Return 0 on
 * success, or -1 on failure.
 */
Initialize a blocking queue  The maximum capacity of the queue is set to
size.  Types that want to be stored in a bqueue must contain a bqueue_node_t,
and offset should give its offset from the start of the struct.  Return 0 on
success, or -1 on failure.
Initialize a blocking queue The maximum capacity of the queue is set to size . Types that want to be stored in a bqueue must contain a bqueue_node_t and offset should give its offset from the start of the struct . Return 0 on success or - 1 on failure .
int
bqueue_init(bqueue_t *q, uint64_t size, size_t node_offset)
{
	list_create(&q->bq_list, node_offset + sizeof (bqueue_node_t),
	    node_offset + offsetof(bqueue_node_t, bqn_node));
	cv_init(&q->bq_add_cv, NULL, CV_DEFAULT, NULL);
	cv_init(&q->bq_pop_cv, NULL, CV_DEFAULT, NULL);
	mutex_init(&q->bq_lock, NULL, MUTEX_DEFAULT, NULL);
	q->bq_node_offset = node_offset;
	q->bq_size = 0;
	q->bq_maxsize = size;
	return (0);
}
int bqueue_init ( bqueue_t * q , uint64_t size , size_t node_offset ) { list_create ( & q -> bq_list , node_offset + sizeof ( bqueue_node_t ) , node_offset + offsetof ( bqueue_node_t , bqn_node ) ) ; cv_init ( & q -> bq_add_cv , NULL , CV_DEFAULT , NULL ) ; cv_init ( & q -> bq_pop_cv , NULL , CV_DEFAULT , NULL ) ; mutex_init ( & q -> bq_lock , NULL , MUTEX_DEFAULT , NULL ) ; q -> bq_node_offset = node_offset ; q -> bq_size = 0 ; q -> bq_maxsize = size ; return ( 0 ) ; }
Initialize a blocking queue  The maximum capacity of the queue is set to
 size.
Initialize a blocking queue The maximum capacity of the queue is set to size .