1249292Smm/*
2249292Smm * CDDL HEADER START
3249292Smm *
4249292Smm * This file and its contents are supplied under the terms of the
5249292Smm * Common Development and Distribution License ("CDDL"), version 1.0.
6249292Smm * You may only use this file in accordance with the terms of version
7249292Smm * 1.0 of the CDDL.
8249292Smm *
9249292Smm * A full copy of the text of the CDDL should have accompanied this
10249292Smm * source.  A copy of the CDDL is also available via the Internet at
11249292Smm * http://www.illumos.org/license/CDDL.
12249292Smm *
13249292Smm * CDDL HEADER END
14249292Smm */
15249292Smm
16249292Smm/*
17249292Smm * Copyright (c) 2012 by Delphix. All rights reserved.
18249292Smm */
19249292Smm
20249292Smm#ifndef	_DT_PQ_H
21249292Smm#define	_DT_PQ_H
22249292Smm
23249292Smm#include <dtrace.h>
24249292Smm
25249292Smm#ifdef	__cplusplus
26249292Smmextern "C" {
27249292Smm#endif
28249292Smm
29249292Smmtypedef uint64_t (*dt_pq_value_f)(void *, void *);
30249292Smm
31249292Smmtypedef struct dt_pq {
32249292Smm	dtrace_hdl_t *dtpq_hdl;		/* dtrace handle */
33249292Smm	void **dtpq_items;		/* array of elements */
34249292Smm	uint_t dtpq_size;		/* count of allocated elements */
35249292Smm	uint_t dtpq_last;		/* next free slot */
36249292Smm	dt_pq_value_f dtpq_value;	/* callback to get the value */
37249292Smm	void *dtpq_arg;			/* callback argument */
38249292Smm} dt_pq_t;
39249292Smm
40249292Smmextern dt_pq_t *dt_pq_init(dtrace_hdl_t *, uint_t size, dt_pq_value_f, void *);
41249292Smmextern void dt_pq_fini(dt_pq_t *);
42249292Smm
43249292Smmextern void dt_pq_insert(dt_pq_t *, void *);
44249292Smmextern void *dt_pq_pop(dt_pq_t *);
45249292Smmextern void *dt_pq_walk(dt_pq_t *, uint_t *);
46249292Smm
47249292Smm#ifdef	__cplusplus
48249292Smm}
49249292Smm#endif
50249292Smm
51249292Smm#endif	/* _DT_PQ_H */
52