线程池类
更多...
#include <threadpool.hpp>
|
| using | ptr = std::unique_ptr< threadpool > |
| | 线程池操作句柄
|
| |
| using | Functor = std::function< void(void)> |
| | 线程池回调函数
|
| |
|
| | threadpool (int thr_count=1) |
| | 构造函数
|
| |
| | ~threadpool () |
| | 析构函数
|
| |
| void | stop () |
| | 停止所有线程
|
| |
| template<typename F , typename... Args> |
| auto | push (F &&func, Args &&...args) -> std::future< decltype(func(args...))> |
| | 传入任务函数到任务池
|
| |
|
| void | entry () |
| | 线程入口函数 从任务池中取出任务执行
|
| |
◆ Functor
◆ ptr
◆ threadpool()
| XuServer::threadpool::threadpool |
( |
int |
thr_count = 1 | ) |
|
|
inline |
◆ ~threadpool()
| XuServer::threadpool::~threadpool |
( |
| ) |
|
|
inline |
◆ entry()
| void XuServer::threadpool::entry |
( |
| ) |
|
|
inlineprivate |
◆ push()
template<typename F , typename... Args>
| auto XuServer::threadpool::push |
( |
F && |
func, |
|
|
Args &&... |
args |
|
) |
| -> std::future<decltype(func(args...))>
|
|
inline |
传入任务函数到任务池
- 模板参数
-
- 参数
-
- 返回
- 自动推导任务函数返回值类型
◆ stop()
| void XuServer::threadpool::stop |
( |
| ) |
|
|
inline |
◆ _cv
| std::condition_variable XuServer::threadpool::_cv |
|
private |
◆ _mutex
| std::mutex XuServer::threadpool::_mutex |
|
private |
◆ _stop
| std::atomic<bool> XuServer::threadpool::_stop |
|
private |
◆ _taskpool
| std::vector<Functor> XuServer::threadpool::_taskpool |
|
private |
◆ _threads
| std::vector<std::thread> XuServer::threadpool::_threads |
|
private |