MCPcopy Create free account
hub / github.com/PDAL/PDAL / work

Method work

pdal/util/ThreadPool.cpp:54–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54void ThreadPool::work()
55{
56 while (true)
57 {
58 std::unique_lock<std::mutex> lock(m_mutex);
59 m_consumeCv.wait(lock, [this]()
60 {
61 return m_tasks.size() || !m_running;
62 });
63
64 if (m_tasks.size())
65 {
66 ++m_outstanding;
67 auto task(std::move(m_tasks.front()));
68 m_tasks.pop();
69
70 lock.unlock();
71
72 // Notify add(), which may be waiting for a spot in the queue.
73 m_produceCv.notify_all();
74
75 std::string err;
76
77 task();
78
79 lock.lock();
80 --m_outstanding;
81 lock.unlock();
82
83 // Notify await(), which may be waiting for a running task.
84 m_produceCv.notify_all();
85 }
86 else if (!m_running)
87 {
88 return;
89 }
90 }
91}
92
93} // namespace pdal
94

Callers

nothing calls this directly

Calls 4

waitMethod · 0.80
unlockMethod · 0.80
lockMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected