Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/senlinzhan/dpool
使用 C++11 实现的动态线程池
https://github.com/senlinzhan/dpool
c-plus-plus-11 dynamic-threadpool high-performance threadpool
Last synced: 5 days 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 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T11:53:44.000Z (9 months ago)
- Last Synced: 2024-03-12T16:33:52.508Z (4 months ago)
- Topics: c-plus-plus-11, dynamic-threadpool, high-performance, threadpool
- Language: C++
- Size: 9.77 KB
- Stars: 120
- Watchers: 3
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-stars - senlinzhan/dpool - 使用 C++11 实现的动态线程池 (C++)
README
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) ![Build status](https://travis-ci.org/senlinzhan/dpool.svg?branch=master)
# 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;
}
```