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