xref: /titanic_51/usr/src/lib/mergeq/workq.h (revision 7fd791373689a6af05e27efec3b1ab556e02aa23)
1*7fd79137SRobert Mustacchi /*
2*7fd79137SRobert Mustacchi  * This file and its contents are supplied under the terms of the
3*7fd79137SRobert Mustacchi  * Common Development and Distribution License ("CDDL"), version 1.0.
4*7fd79137SRobert Mustacchi  * You may only use this file in accordance with the terms of version
5*7fd79137SRobert Mustacchi  * 1.0 of the CDDL.
6*7fd79137SRobert Mustacchi  *
7*7fd79137SRobert Mustacchi  * A full copy of the text of the CDDL should have accompanied this
8*7fd79137SRobert Mustacchi  * source.  A copy of the CDDL is also available via the Internet at
9*7fd79137SRobert Mustacchi  * http://www.illumos.org/license/CDDL.
10*7fd79137SRobert Mustacchi  */
11*7fd79137SRobert Mustacchi 
12*7fd79137SRobert Mustacchi /*
13*7fd79137SRobert Mustacchi  * Copyright 2015 Joyent, Inc.
14*7fd79137SRobert Mustacchi  */
15*7fd79137SRobert Mustacchi 
16*7fd79137SRobert Mustacchi #ifndef _WORKQ_H
17*7fd79137SRobert Mustacchi #define	_WORKQ_H
18*7fd79137SRobert Mustacchi 
19*7fd79137SRobert Mustacchi /*
20*7fd79137SRobert Mustacchi  * workq library routines
21*7fd79137SRobert Mustacchi  */
22*7fd79137SRobert Mustacchi 
23*7fd79137SRobert Mustacchi #include <sys/types.h>
24*7fd79137SRobert Mustacchi #include <stdint.h>
25*7fd79137SRobert Mustacchi 
26*7fd79137SRobert Mustacchi #ifdef __cplusplus
27*7fd79137SRobert Mustacchi extern "C" {
28*7fd79137SRobert Mustacchi #endif
29*7fd79137SRobert Mustacchi 
30*7fd79137SRobert Mustacchi typedef struct workq workq_t;
31*7fd79137SRobert Mustacchi typedef int (workq_proc_f)(void *, void *);
32*7fd79137SRobert Mustacchi 
33*7fd79137SRobert Mustacchi extern int workq_init(workq_t **, uint_t);
34*7fd79137SRobert Mustacchi extern void workq_fini(workq_t *);
35*7fd79137SRobert Mustacchi 
36*7fd79137SRobert Mustacchi extern int workq_add(workq_t *, void *);
37*7fd79137SRobert Mustacchi 
38*7fd79137SRobert Mustacchi #define	WORKQ_ERROR	(-1)
39*7fd79137SRobert Mustacchi #define	WORKQ_UERROR	(-2)
40*7fd79137SRobert Mustacchi extern int workq_work(workq_t *, workq_proc_f *, void *, int *);
41*7fd79137SRobert Mustacchi 
42*7fd79137SRobert Mustacchi /*
43*7fd79137SRobert Mustacchi  * Routines consumers need to implement
44*7fd79137SRobert Mustacchi  */
45*7fd79137SRobert Mustacchi extern void *workq_alloc(size_t);
46*7fd79137SRobert Mustacchi extern void workq_free(void *, size_t);
47*7fd79137SRobert Mustacchi 
48*7fd79137SRobert Mustacchi #ifdef __cplusplus
49*7fd79137SRobert Mustacchi }
50*7fd79137SRobert Mustacchi #endif
51*7fd79137SRobert Mustacchi 
52*7fd79137SRobert Mustacchi #endif /* _WORKQ_H */
53