xref: /freebsd/cddl/compat/opensolaris/include/thread_pool.h (revision afb8674c798ab3348c48e1bc37d746f04f647c7c)
1*afb8674cSAlexander Motin /*
2*afb8674cSAlexander Motin  * CDDL HEADER START
310b9d77bSPawel Jakub Dawidek  *
4*afb8674cSAlexander Motin  * The contents of this file are subject to the terms of the
5*afb8674cSAlexander Motin  * Common Development and Distribution License (the "License").
6*afb8674cSAlexander Motin  * You may not use this file except in compliance with the License.
710b9d77bSPawel Jakub Dawidek  *
8*afb8674cSAlexander Motin  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*afb8674cSAlexander Motin  * or http://www.opensolaris.org/os/licensing.
10*afb8674cSAlexander Motin  * See the License for the specific language governing permissions
11*afb8674cSAlexander Motin  * and limitations under the License.
1210b9d77bSPawel Jakub Dawidek  *
13*afb8674cSAlexander Motin  * When distributing Covered Code, include this CDDL HEADER in each
14*afb8674cSAlexander Motin  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*afb8674cSAlexander Motin  * If applicable, add the following below this CDDL HEADER, with the
16*afb8674cSAlexander Motin  * fields enclosed by brackets "[]" replaced with your own identifying
17*afb8674cSAlexander Motin  * information: Portions Copyright [yyyy] [name of copyright owner]
18*afb8674cSAlexander Motin  *
19*afb8674cSAlexander Motin  * CDDL HEADER END
20*afb8674cSAlexander Motin  */
21*afb8674cSAlexander Motin 
22*afb8674cSAlexander Motin /*
23*afb8674cSAlexander Motin  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*afb8674cSAlexander Motin  * Use is subject to license terms.
25*afb8674cSAlexander Motin  */
26*afb8674cSAlexander Motin 
27*afb8674cSAlexander Motin /*
2810b9d77bSPawel Jakub Dawidek  * $FreeBSD$
2910b9d77bSPawel Jakub Dawidek  */
3010b9d77bSPawel Jakub Dawidek 
31*afb8674cSAlexander Motin #ifndef	_THREAD_POOL_H_
32*afb8674cSAlexander Motin #define	_THREAD_POOL_H_
3310b9d77bSPawel Jakub Dawidek 
34*afb8674cSAlexander Motin #pragma ident	"%Z%%M%	%I%	%E% SMI"
3510b9d77bSPawel Jakub Dawidek 
36*afb8674cSAlexander Motin #include <sys/types.h>
37*afb8674cSAlexander Motin #include <thread.h>
38*afb8674cSAlexander Motin #include <pthread.h>
3910b9d77bSPawel Jakub Dawidek 
40*afb8674cSAlexander Motin #ifdef	__cplusplus
41*afb8674cSAlexander Motin extern "C" {
42*afb8674cSAlexander Motin #endif
43*afb8674cSAlexander Motin 
44*afb8674cSAlexander Motin typedef	struct tpool tpool_t;	/* opaque thread pool descriptor */
45*afb8674cSAlexander Motin 
46*afb8674cSAlexander Motin #if defined(__STDC__)
47*afb8674cSAlexander Motin 
48*afb8674cSAlexander Motin extern	tpool_t	*tpool_create(uint_t min_threads, uint_t max_threads,
49*afb8674cSAlexander Motin 			uint_t linger, pthread_attr_t *attr);
50*afb8674cSAlexander Motin extern	int	tpool_dispatch(tpool_t *tpool,
51*afb8674cSAlexander Motin 			void (*func)(void *), void *arg);
52*afb8674cSAlexander Motin extern	void	tpool_destroy(tpool_t *tpool);
53*afb8674cSAlexander Motin extern	void	tpool_abandon(tpool_t *tpool);
54*afb8674cSAlexander Motin extern	void	tpool_wait(tpool_t *tpool);
55*afb8674cSAlexander Motin extern	void	tpool_suspend(tpool_t *tpool);
56*afb8674cSAlexander Motin extern	int	tpool_suspended(tpool_t *tpool);
57*afb8674cSAlexander Motin extern	void	tpool_resume(tpool_t *tpool);
58*afb8674cSAlexander Motin extern	int	tpool_member(tpool_t *tpool);
59*afb8674cSAlexander Motin 
60*afb8674cSAlexander Motin #else	/* Non ANSI */
61*afb8674cSAlexander Motin 
62*afb8674cSAlexander Motin extern	tpool_t	*tpool_create();
63*afb8674cSAlexander Motin extern	int	tpool_dispatch();
64*afb8674cSAlexander Motin extern	void	tpool_destroy();
65*afb8674cSAlexander Motin extern	void	tpool_abandon();
66*afb8674cSAlexander Motin extern	void	tpool_wait();
67*afb8674cSAlexander Motin extern	void	tpool_suspend();
68*afb8674cSAlexander Motin extern	int	tpool_suspended();
69*afb8674cSAlexander Motin extern	void	tpool_resume();
70*afb8674cSAlexander Motin extern	int	tpool_member();
71*afb8674cSAlexander Motin 
72*afb8674cSAlexander Motin #endif	/* __STDC__ */
73*afb8674cSAlexander Motin 
74*afb8674cSAlexander Motin #ifdef	__cplusplus
75*afb8674cSAlexander Motin }
76*afb8674cSAlexander Motin #endif
77*afb8674cSAlexander Motin 
78*afb8674cSAlexander Motin #endif	/* _THREAD_POOL_H_ */
79