Skip to content

Commit

Permalink
Naive multithreading support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sir-NoChill committed Sep 8, 2024
1 parent 4894575 commit 6b30ab5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/testharness/TestHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,28 @@ void swap(TestResult& first, TestResult& second) {

// Builds TestSet during object creation.
bool TestHarness::runTests() {
bool failed = false;
std::vector<std::thread> threadPool;

// Initialize the threads
// Iterate over executables.
for (auto exePair : cfg.getExecutables()) {
// Iterate over toolchains.
for (auto& tcPair : cfg.getToolChains()) {
std::thread t(&TestHarness::threadRunTestsForToolChain, this, tcPair.first, exePair.first);
threadPool.push_back(std::move(t));
}
}

bool failed = false;
// Iterate over executables.
for (auto exePair : cfg.getExecutables()) {
// Iterate over toolchains.
for (auto& tcPair : cfg.getToolChains()) {
if (aggregateTestResultsForToolChain(tcPair.first, exePair.first) == 1)
failed = true;

t.join();
threadPool.back().join();
threadPool.pop_back();
}
}
return failed;
Expand Down

0 comments on commit 6b30ab5

Please sign in to comment.