| 15 | bool stop; |
| 16 | public: |
| 17 | ThreadPool(size_t count) : stop(false) |
| 18 | { |
| 19 | for (size_t i = 0; i < count; i++) |
| 20 | { |
| 21 | threads.emplace_back( |
| 22 | [this] |
| 23 | { |
| 24 | while (true) |
| 25 | { |
| 26 | std::function<void()> task; |
| 27 | { |
| 28 | std::unique_lock<std::mutex> lock(this->mutex); |
| 29 | this->condition.wait(lock, [this] { return this->stop || !this->queue.empty(); }); |
| 30 | if (this->stop && this->queue.empty()) return; |
| 31 | task = std::move(this->queue.front()); |
| 32 | this->queue.pop(); |
| 33 | } |
| 34 | task(); |
| 35 | } |
| 36 | } |
| 37 | ); |
| 38 | } |
| 39 | } |
| 40 | ~ThreadPool() |
| 41 | { |
| 42 | { |
nothing calls this directly
no outgoing calls
no test coverage detected