Threads Pool - C Language
thpool.h
00001 
00012 #ifndef POOL_H_
00013 #define POOL_H_
00014 
00015 #include <stdlib.h>
00016 #include <pthread.h>
00017 #include <signal.h>
00018 
00019 #include "errore.h"
00020 
00021 #ifndef NULL
00022 #define NULL   ((void *) 0)
00023 #endif
00024 
00026 typedef struct joblist{
00028         void *(*start_routine)(void*);
00030         void * arg;
00032         struct joblist * next;
00033 } joblist;
00034 
00036 typedef struct ThreadPool{
00038         volatile sig_atomic_t quitflag;
00040         volatile sig_atomic_t shutdown;
00041         sigset_t * signalmask;          
00042         int pool_size;                          
00043         int job_max;                            
00044         int job_size;                           
00045         joblist * firstjob;                     
00046         joblist * lastjob;                      
00047         pthread_t * tids;                       
00049         pthread_mutex_t lock;
00050         pthread_cond_t notempty;        
00051         pthread_cond_t empty;           
00052 } th_pool;
00053 
00065 th_pool * poolInit(int dim, int job_max, sigset_t *set);
00066 
00083 int poolDispatcher(th_pool *pool, void *(*start_routine)(void*), void *arg);
00084 
00099 int poolDestroy(th_pool *pool);
00100 
00101 #endif /* POOL_H_ */