Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diegostamigni/thread_pool
A simple thread_pool implementation in C++11 that is based on priority queues.
https://github.com/diegostamigni/thread_pool
Last synced: about 2 months ago
JSON representation
A simple thread_pool implementation in C++11 that is based on priority queues.
- Host: GitHub
- URL: https://github.com/diegostamigni/thread_pool
- Owner: diegostamigni
- Created: 2015-07-26T21:36:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-28T08:48:01.000Z (over 9 years ago)
- Last Synced: 2023-04-03T17:46:47.955Z (almost 2 years ago)
- Language: C++
- Homepage: http://www.diegostamigni.com
- Size: 121 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# thread_pool
### MIT LicenseThis is a simple implementation of a thread_pool using the C++ STL APIs. For now, I require boost::thread (and its releated deps, boost::system) in order to have a method to ::interrupt() not-joinable thread. In the future, I'll remove that deps and improving the `pausing/killing' state of the thread_pool
Pull requests are appreciated.Objects that can be enqueued inside ds::thread_pool must have implemented the function operator ```bool operator()();``` because the pool itself will call that operator in order to execute what the object is supposed to do.
```c++
class task {
public:
explicit task(const std::string &c)
: m_value{c} {}
virtual bool operator()() {
std::cout << m_value << std::endl;
return true;
}private:
std::string m_value;
};
```#####Usage:
```c++
ds::thread_pool t;
t.enqueue(ds::priority_t::LOW, "!");
t.enqueue(ds::priority_t::MED, "world");
t.enqueue(ds::priority_t::HIGH, "hello");
```#####Output:
hello
world
!