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 */ 2910b9d77bSPawel Jakub Dawidek 30*afb8674cSAlexander Motin #ifndef _THREAD_POOL_H_ 31*afb8674cSAlexander Motin #define _THREAD_POOL_H_ 3210b9d77bSPawel Jakub Dawidek 33*afb8674cSAlexander Motin #pragma ident "%Z%%M% %I% %E% SMI" 3410b9d77bSPawel Jakub Dawidek 35*afb8674cSAlexander Motin #include <sys/types.h> 36*afb8674cSAlexander Motin #include <thread.h> 37*afb8674cSAlexander Motin #include <pthread.h> 3810b9d77bSPawel Jakub Dawidek 39*afb8674cSAlexander Motin #ifdef __cplusplus 40*afb8674cSAlexander Motin extern "C" { 41*afb8674cSAlexander Motin #endif 42*afb8674cSAlexander Motin 43*afb8674cSAlexander Motin typedef struct tpool tpool_t; /* opaque thread pool descriptor */ 44*afb8674cSAlexander Motin 45*afb8674cSAlexander Motin #if defined(__STDC__) 46*afb8674cSAlexander Motin 47*afb8674cSAlexander Motin extern tpool_t *tpool_create(uint_t min_threads, uint_t max_threads, 48*afb8674cSAlexander Motin uint_t linger, pthread_attr_t *attr); 49*afb8674cSAlexander Motin extern int tpool_dispatch(tpool_t *tpool, 50*afb8674cSAlexander Motin void (*func)(void *), void *arg); 51*afb8674cSAlexander Motin extern void tpool_destroy(tpool_t *tpool); 52*afb8674cSAlexander Motin extern void tpool_abandon(tpool_t *tpool); 53*afb8674cSAlexander Motin extern void tpool_wait(tpool_t *tpool); 54*afb8674cSAlexander Motin extern void tpool_suspend(tpool_t *tpool); 55*afb8674cSAlexander Motin extern int tpool_suspended(tpool_t *tpool); 56*afb8674cSAlexander Motin extern void tpool_resume(tpool_t *tpool); 57*afb8674cSAlexander Motin extern int tpool_member(tpool_t *tpool); 58*afb8674cSAlexander Motin 59*afb8674cSAlexander Motin #else /* Non ANSI */ 60*afb8674cSAlexander Motin 61*afb8674cSAlexander Motin extern tpool_t *tpool_create(); 62*afb8674cSAlexander Motin extern int tpool_dispatch(); 63*afb8674cSAlexander Motin extern void tpool_destroy(); 64*afb8674cSAlexander Motin extern void tpool_abandon(); 65*afb8674cSAlexander Motin extern void tpool_wait(); 66*afb8674cSAlexander Motin extern void tpool_suspend(); 67*afb8674cSAlexander Motin extern int tpool_suspended(); 68*afb8674cSAlexander Motin extern void tpool_resume(); 69*afb8674cSAlexander Motin extern int tpool_member(); 70*afb8674cSAlexander Motin 71*afb8674cSAlexander Motin #endif /* __STDC__ */ 72*afb8674cSAlexander Motin 73*afb8674cSAlexander Motin #ifdef __cplusplus 74*afb8674cSAlexander Motin } 75*afb8674cSAlexander Motin #endif 76*afb8674cSAlexander Motin 77*afb8674cSAlexander Motin #endif /* _THREAD_POOL_H_ */ 78