Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6b30ab5

Browse files
committedSep 8, 2024··
Naive multithreading support
Simply spawns a thread for every toolchain. Note that this would probably brick a computer without a lot of cores or running tests with a whole bunch of packages. Implementation will need to limit the number of spawnable threads in the future.
1 parent 4894575 commit 6b30ab5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
 

‎src/testharness/TestHarness.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,28 @@ void swap(TestResult& first, TestResult& second) {
2020

2121
// Builds TestSet during object creation.
2222
bool TestHarness::runTests() {
23-
bool failed = false;
23+
std::vector<std::thread> threadPool;
24+
25+
// Initialize the threads
2426
// Iterate over executables.
2527
for (auto exePair : cfg.getExecutables()) {
2628
// Iterate over toolchains.
2729
for (auto& tcPair : cfg.getToolChains()) {
2830
std::thread t(&TestHarness::threadRunTestsForToolChain, this, tcPair.first, exePair.first);
31+
threadPool.push_back(std::move(t));
32+
}
33+
}
34+
35+
bool failed = false;
36+
// Iterate over executables.
37+
for (auto exePair : cfg.getExecutables()) {
38+
// Iterate over toolchains.
39+
for (auto& tcPair : cfg.getToolChains()) {
2940
if (aggregateTestResultsForToolChain(tcPair.first, exePair.first) == 1)
3041
failed = true;
3142

32-
t.join();
43+
threadPool.back().join();
44+
threadPool.pop_back();
3345
}
3446
}
3547
return failed;

0 commit comments

Comments
 (0)
Please sign in to comment.