xref: /illumos-gate/usr/src/cmd/syslogd/dataq.h (revision 9164a50bf932130cbb5097a16f6986873ce0e6e5)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1996-2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_DATAQ_H
28 #define	_DATAQ_H
29 
30 #include "llt.h"
31 
32 typedef struct dataq_data {
33 	ll_t list;
34 	void *data;
35 } dataq_data_t;
36 
37 typedef struct dataq_waiter {
38 	ll_t list;
39 	pthread_cond_t cv;
40 	int wakeup;
41 } dataq_waiter_t;
42 
43 typedef struct dataq {
44 	pthread_mutex_t lock;
45 	int num_data;
46 	int num_waiters;
47 	llh_t data;
48 	llh_t waiters;
49 } dataq_t;
50 
51 int dataq_init(dataq_t *ptr);
52 int dataq_enqueue(dataq_t *dataq, void *in);
53 int dataq_dequeue(dataq_t *dataq, void **outptr, int);
54 int dataq_destroy(dataq_t *dataq);
55 
56 #endif	/* _DATAQ_H */
57