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