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

Method start

source/src/thread.h:69–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 bool active()
68 {
69 std::unique_lock<std::mutex> lock(m_mutex);
70 if (m_worker_list.empty()) return false;
71 return !m_worker_list.back()->m_stop;
72 }
73
74 template<class QiWorkers, class ...Args>
75 void start(Args&&... args)
76 {
77 std::unique_lock<std::mutex> lock(m_mutex);
78 for (auto& i : m_worker_list) i->m_stop = true;
79
80 auto& worker = m_worker_list.emplace_back(new QiWorkers(std::forward<Args>(args)...));
81 std::thread([worker_refcopy = worker] { worker_refcopy->run(); worker_refcopy->m_stop = true; }).detach();
82
83 bool exist = false;
84 do {
85 exist = false;
86 for (auto i = m_worker_list.begin(); i != m_worker_list.end(); i++)
87 {
88 if ((*i)->m_stop)
89 {
90 m_worker_list.erase(i);
91 exist = true;
92 break;
93 }

Callers

nothing calls this directly

Calls 4

beginMethod · 0.80
endMethod · 0.80
eraseMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected