Merge "libutil: thread-pool: ensure threads finished on error" into main

This commit is contained in:
eldritch horrors
2025-01-15 22:33:30 +00:00
committed by Gerrit Code Review
2 changed files with 8 additions and 7 deletions
+2 -6
View File
@@ -306,9 +306,7 @@ void Store::addMultipleToStore(
act.progress(nrDone, pathsToCopy.size(), nrRunning, nrFailed);
};
ThreadPool pool{"addMultipleToStore pool"};
processGraph<StorePath>(pool,
processGraph<StorePath>("addMultipleToStore pool",
storePathsToAdd,
[&](const StorePath & path) {
@@ -1137,12 +1135,10 @@ std::map<StorePath, StorePath> copyPaths(
}
auto pathsMap = copyPaths(srcStore, dstStore, storePaths, repair, checkSigs, substitute);
ThreadPool pool{"copyPaths pool"};
try {
// Copy the realisation closure
processGraph<Realisation>(
pool, Realisation::closure(srcStore, toplevelRealisations),
"copyPaths pool", Realisation::closure(srcStore, toplevelRealisations),
[&](const Realisation & current) -> std::set<Realisation> {
std::set<Realisation> children;
for (const auto & [drvOutput, _] : current.dependentRealisations) {
+6 -1
View File
@@ -85,7 +85,7 @@ private:
*/
template<typename T>
void processGraph(
ThreadPool & pool,
const char *poolName,
const std::set<T> & nodes,
std::function<std::set<T>(const T &)> getEdges,
std::function<void(const T &)> processNode)
@@ -99,6 +99,11 @@ void processGraph(
std::function<void(const T &)> worker;
/* Create pool last to ensure threads are stopped before other destructors
* run */
ThreadPool pool{poolName};
worker = [&](const T & node) {
{