00001 /* 00002 * Copyright (C) 2005 Abel Bennett. 00003 * 00004 * This is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with the GNU C Library; if not, write to the Free 00016 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00017 * 02111-1307 USA. 00018 */ 00019 00032 #ifndef _PTHREAD_SUBPOOL_ 00033 #define _PTHREAD_SUBPOOL_ 00034 00035 00036 #include <pthread_pool.h> 00037 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 00047 typedef struct 00048 { 00052 pthread_mutexattr_t mutex_attr; 00053 00057 pthread_condattr_t cond_attr; 00058 00059 } pthread_subpoolattr_t; 00060 00061 00065 typedef struct 00066 { 00070 pthread_mutex_t lock; 00071 00075 pthread_cond_t cond; 00076 00080 pthread_pool_t * pool; 00081 00085 int jobs; 00086 00087 } pthread_subpool_t; 00088 00089 00099 extern int pthread_subpool_init(pthread_subpool_t * subpool, 00100 const pthread_subpoolattr_t * attr, 00101 pthread_pool_t * pool); 00102 00110 extern int pthread_subpool_destroy(pthread_subpool_t * subpool); 00111 00121 extern int pthread_subpool_addwork(pthread_subpool_t * subpool, 00122 void (*routine)(void *), void * arg); 00123 00131 extern int pthread_subpool_finishjob(pthread_subpool_t * subpool); 00132 00140 extern int pthread_subpool_finishwork(pthread_subpool_t * subpool); 00141 00149 extern int pthread_subpoolattr_init(pthread_subpoolattr_t * attr); 00150 00158 extern int pthread_subpoolattr_destroy(pthread_subpoolattr_t * attr); 00159 00160 #if (_POSIX_THREAD_PROCESS_SHARED == 1) 00161 00169 extern int pthread_subpoolattr_getpshared(const pthread_subpoolattr_t * attr, 00170 int * pshared); 00171 00180 extern int pthread_subpoolattr_setpshared(pthread_subpoolattr_t * attr, 00181 const int pshared); 00182 #endif 00183 00184 #ifdef __cplusplus 00185 } 00186 #endif 00187 00188 #endif