https://github.com/yigitest/thread_pool
C++ thread pool
https://github.com/yigitest/thread_pool
cpp cpp11 futures single-header thread-pool
Last synced: 12 months ago
JSON representation
C++ thread pool
- Host: GitHub
- URL: https://github.com/yigitest/thread_pool
- Owner: yigitest
- License: mit
- Created: 2017-01-07T14:16:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-11T06:24:20.000Z (over 9 years ago)
- Last Synced: 2025-02-08T14:09:35.714Z (over 1 year ago)
- Topics: cpp, cpp11, futures, single-header, thread-pool
- Language: C++
- Size: 71.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ThreadPool
Simple C++11 thread pool.
## Setup / Usage
```cpp
#include "thread_pool.h"
#include
class ApplyFoo {
public:
int operator()(int answer) const {
return answer;
}
};
int main (int argc, char * argv[]) {
// create thread pool with 2 threads.
tp::ThreadPool tp(2);
// enqueue and store future
auto result = tp.enqueue(ApplyFoo(), 42);
// get result from future
std::cout << result.get() << std::endl;
}
```
## Running Tests With CMake
```
mkdir build
cd build
cmake ..
make
make test
```
## Known Issues and TODOs
* ~~DONE an api call for waiting until all tasks done.~~
* TODO work stealing.
* TODO map/reduce.