/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/utils/eh_thread_pool.h

Go to the documentation of this file.
00001 #ifndef __EH_THREAD_POOL_H__
00002 #define __EH_THREAD_POOL_H__
00003 
00004 #include <pthread.h>
00005 
00006 typedef struct tpool_work
00007 {
00008    void (*routine)();
00009    void *arg;
00010    struct tpool_work *next;
00011 } tpool_work_t;
00012 
00013 typedef struct tpool
00014 {
00015    int num_threads;
00016    int max_queue_size;
00017 
00018    int do_not_block_when_full;
00019 
00020    pthread_t *threads;
00021    int cur_queue_size;
00022    tpool_work_t *queue_head;
00023    tpool_work_t *queue_tail;
00024    pthread_mutex_t queue_lock;
00025    pthread_cond_t queue_not_empty;
00026    pthread_cond_t queue_not_full;
00027    pthread_cond_t queue_empty;
00028    int queue_closed;
00029    int shutdown;
00030 } *tpool_t;
00031 
00032 void tpool_init(tpool_t *tpoolp, int num_worker_threads, int max_queue_size, int do_not_block_when_full);
00033 void tpool_thread( tpool_t tpool );
00034 int  tpool_add_work( tpool_t tpool , void *routine , void *arg );
00035 int  tpool_destroy( tpool_t tpool , int finish );
00036 
00037 #endif /* eh_thread_pool.h */

Generated on Fri Jan 4 18:04:16 2008 for sedflux by  doxygen 1.5.2