一个线程池的简单模型

940阅读 0评论2010-05-26 chinaltang
分类:LINUX

1 #include
  2 #include
  3 typedef struct work{
  4     void* (*thread)(void*);
  5     void * arg;
  6     struct work *next;
  7 }threadpool_work;
  8
  9 typedef struct threadpool{
10     threadpool_work* head;
11     pthread_t* pid;
12     int current_size;
13     int max_thread_size;
14     pthread_mutex_t list_lock;
15     pthread_cond_t work_avilable;
16     int shutdown;
17 }*threadpool_t;
18
19 void threadpool_init(threadpool_t* tpool,int max_thread_size);
20 void threadpool_add_work(threadpool_t* tpool,void* (*pthread)(void *),void* arg);
21 void* threadpool_get_work(threadpool_t* tpool);
22 void threadpool_destroy(threadpool_t* tpool);
上一篇:IPv4到IPv6的变化
下一篇:在linux下搭建libcap开发环境