https://github.com/senlinzhan/dpool
使用 C++11 实现的动态线程池
https://github.com/senlinzhan/dpool
c-plus-plus-11 dynamic-threadpool high-performance threadpool
Last synced: 2 months ago
JSON representation
使用 C++11 实现的动态线程池
- Host: GitHub
- URL: https://github.com/senlinzhan/dpool
- Owner: senlinzhan
- License: mit
- Created: 2017-04-30T02:25:13.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T11:53:44.000Z (over 1 year ago)
- Last Synced: 2024-10-27T20:19:49.321Z (7 months ago)
- Topics: c-plus-plus-11, dynamic-threadpool, high-performance, threadpool
- Language: C++
- Size: 9.77 KB
- Stars: 172
- Watchers: 3
- Forks: 24
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
 
# dpool使用 C++11 实现的动态线程池,主要特性:
- 使用简单,不易出错。
- 支持线程复用,提升性能。
- 支持懒惰创建线程。
- 必要时自动回收空闲的线程。## 快速上手
```C++
#include "ThreadPool.hpp"
#includeint compute(int a, int b)
{
return a + b;
}int main()
{
// 设置最大线程数为 10
dpool::ThreadPool pool(10);auto fut = pool.submit(compute, 100, 100);
std::cout << "100 + 100 = " << fut.get() << std::endl;
return 0;
}
```