Threads Pool - C Language
pool.h
Vai alla documentazione di questo file.
00001 
00012 #ifndef POOL_H_
00013 #define POOL_H_
00014 
00015 #include <stdlib.h>
00016 #include <pthread.h>
00017 #include <signal.h>
00018 
00019 #ifndef NULL
00020 #define NULL   ((void *) 0)
00021 #endif
00022 
00023 #ifndef ESHUTDOWN
00024 #define ESHUTDOWN 108
00025 #endif
00026 
00028 typedef struct joblist{
00030         void *(*start_routine)(void*);
00032         void * arg;
00034         struct joblist * next;
00035 } joblist;
00036 
00038 typedef struct ThreadPool{
00040         volatile sig_atomic_t quitflag;
00042         volatile sig_atomic_t shutdown;
00043         sigset_t * signalmask;          
00044         int pool_size;                          
00045         int job_max;                            
00046         int job_size;                           
00047         joblist * firstjob;                     
00048         joblist * lastjob;                      
00049         pthread_t * tids;                       
00051         pthread_mutex_t lock;
00052         pthread_cond_t notempty;        
00053         pthread_cond_t empty;           
00054 } th_pool;
00055 
00067 th_pool * poolInit(int dim, int job_max, sigset_t *set);
00068 
00085 int poolDispatcher(th_pool *pool, void *(*start_routine)(void*), void *arg);
00086 
00101 int poolDestroy(th_pool *pool);
00102 
00103 #endif /* POOL_H_ */