https://github.com/notdodo/threadpool
A very fast and lightweight C++14 thread pool library (general purpose)
https://github.com/notdodo/threadpool
threadpool
Last synced: about 1 month ago
JSON representation
A very fast and lightweight C++14 thread pool library (general purpose)
- Host: GitHub
- URL: https://github.com/notdodo/threadpool
- Owner: notdodo
- License: gpl-3.0
- Created: 2016-02-22T09:18:47.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2021-12-13T08:12:49.000Z (over 4 years ago)
- Last Synced: 2025-04-11T11:48:10.191Z (12 months ago)
- Topics: threadpool
- Language: C++
- Homepage:
- Size: 17.6 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ThreadPool
A very fast and lightweight C++14 thread pool library (general purpose)
# Example
The library is very easy to use: just `#include` it to your project, create the object `ThreadPool pool(_numberofcores)` and add tasks to pool using `AddTask` functions.
```c++
#include "ThreadPool.h"
#include
int main(int argc, char **argv) {
// number of task to exec
const int TASKS=100000;
ThreadPool pool(std::thread::hardware_concurrency() + 1);
for(int i = 0; i < TASKS; i++)
pool.AddTask([i]{ std::cout << "I'm task # " << i << " doing some stuffs" << std::endl; });
// wait for all tasks to finish, not necessary in this case: when `pool` goes out of scope it will automatically call `JoinAll`.
pool.JoinAll();
return 0;
}
```
### Development
Add support for `future`
Add support for multitemplate functions