Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7387
  • 博文数量: 18
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 0
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-05 23:29
文章分类

全部博文(18)

文章存档

2017年(17)

2015年(1)

我的朋友
最近访客

分类: LINUX

2017-06-11 00:41:17

原文地址:一个线程池的简单模型 作者:chinaltang

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);
阅读(104) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~