1 Star 0 Fork 26

柏松/threadpool

forked from niukey/threadpool 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
threadpool_t.h 905 Bytes
一键复制 编辑 原始数据 按行查看 历史
akzi 提交于 2015-01-22 13:33 . add threadpool files
#pragma once
#include "stddef.hpp"
#include "task_t.hpp"
#include "thread_t.h"
#include "task_queue_t.h"
class threadpool_t
{
public:
typedef std::lock_guard<std::mutex> lock_guard_t;
threadpool_t(void);
~threadpool_t(void);
void add_task(task_t &task_);
void init(uint32_t max_thread_num, uint32_t idle_timeout);
void destroy();
private:
void init_thread(uint32_t max_thread_num, uint32_t idle_timeout);
void create_a_new_thread();
bool pull_task(task_ptr_t &task_);
void thread_exit_pro(uint32_t tid_);
uint32_t next_tid();
typedef std::list<thread_ptr_t> thread_list_t;
thread_t::pull_task_fun_t pull_task_fun;
thread_t::exit_fun_t thread_exit_fun;
thread_list_t alive_thread_list;
thread_list_t dead_thread_list;
task_queue_t task_queue;
std::mutex thread_list_mutex;
uint32_t mini_thread_count;
uint32_t max_thread_num;
uint32_t idle_timeout;
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/poisson/threadpool.git
git@gitee.com:poisson/threadpool.git
poisson
threadpool
threadpool
master

搜索帮助