文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>一个线程池的简单模型

一个线程池的简单模型

时间:2010-05-26  来源:chinaltang

1 #include<pthread.h>
  2 #include<semaphore.h>
  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);
相关阅读 更多 +
排行榜 更多 +
杖剑传说切换技能方案指南

杖剑传说切换技能方案指南

冒险解谜 下载
都市毁灭模拟器

都市毁灭模拟器

音乐节奏 下载
神探诡事录器门位置一览

神探诡事录器门位置一览

冒险解谜 下载