现在的位置: 首页 > 综合 > 正文

分享一个c线程池实现代码

2013年03月29日 ⁄ 综合 ⁄ 共 417字 ⁄ 字号 评论关闭

下载地址:http://download.csdn.net/detail/xuqianghit/3823740 内附使用示例及makefile文件

接口比较简单:

threadpool create_threadpool(int num_threads_in_pool);
void dispatch(threadpool from_me, dispatch_fn dispatch_to_here,
              void *arg);
void destroy_threadpool(threadpool destroyme);

其中dispatch函数就是向threadpool中添加执行的线程,注意的是:

1. 每个添加的线程仅能运行一次

2. 线程池的调度策略是先来先服务(内部使用链表实现)的策略,没有优先级的概念

3. 线程池不能自动扩充大小。

这里是一篇关于线程池的简单介绍:http://blog.csdn.net/axman/article/details/1481197

抱歉!评论已关闭.