Merge "libutil: thread-pool: ensure threads finished on error" into main
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user