MCPcopy Create free account
hub / github.com/TomClabault/HIPRT-Path-Tracer / join_all_threads

Method join_all_threads

src/Threads/ThreadManager.h:163–205  ·  view source on GitHub ↗

* Joins all the threads that have been started so far except the threads * launch with a key in the 'execeptions' vector passed as parameter */

Source from the content-addressed store, hash-verified

161 * launch with a key in the 'execeptions' vector passed as parameter
162 */
163 static void join_all_threads(const std::unordered_set<std::string>& exceptions = {})
164 {
165 // Joining all the threads and their dependencies
166 for (const auto& key_to_threads : m_threads_map)
167 {
168 std::deque<std::string> dependencies_to_wait_for;
169 std::deque<std::string> dependencies_to_analyze;
170
171 const std::string& thread_key = key_to_threads.first;
172 if (exceptions.find(thread_key) != exceptions.end())
173 // This thread is in the exception list. Not joining these threads
174 continue;
175
176 if (!m_dependencies[thread_key].empty())
177 for (const std::string& dependency : m_dependencies[thread_key])
178 dependencies_to_analyze.push_back(dependency);
179 // Pushing the thread key itself we want to wait for and then we'll
180 // push its dependencies in front of it so that we wait for the dependencies first
181 dependencies_to_wait_for.push_front(thread_key);
182
183 while (!dependencies_to_analyze.empty())
184 {
185 std::string new_dependency = dependencies_to_analyze.front();
186 dependencies_to_analyze.pop_front();
187 dependencies_to_wait_for.push_front(new_dependency);
188
189 const std::unordered_set<std::string>& dependencies = m_dependencies[new_dependency];
190 for (const std::string& dependency : dependencies)
191 dependencies_to_analyze.push_front(dependency);
192 }
193
194 std::unordered_set<std::string> dependencies_already_joined;
195 for (const std::string& dependency : dependencies_to_wait_for)
196 {
197 if (dependencies_already_joined.find(dependency) == dependencies_already_joined.end())
198 {
199 // Dependency not joined yet
200 dependencies_already_joined.insert(dependency);
201 join_threads(dependency);
202 }
203 }
204 }
205 }
206
207 static void detach_threads(const std::string& key)
208 {

Callers

nothing calls this directly

Calls 2

insertMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected