An open API service indexing awesome lists of open source software.

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

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.