MCPcopy Create free account
hub / github.com/ChiyukiGana/Quickinput / ThreadPool

Method ThreadPool

source/src/tools/threadpool.h:17–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15 bool stop;
16public:
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 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected