diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2017-11-06 13:36:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-06 13:36:28 +0100 |
commit | dc30856141a1ef3958dfe230611d9447d7a13957 (patch) | |
tree | 0cbae2fe44665a0c2773c3c14cdcc4501589383c /src | |
parent | 7a4d9574d9275426e31bb2b3fbb8515600d233c4 (diff) | |
parent | 0f9a7225ab47fe313db41f4019177be8fb84a1dd (diff) |
Merge pull request #1632 from AmineChikhaoui/sigint-copy
run query paths in parallel during nix copy and handle SIGINT
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/store-api.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index c57e42fec..3631e1b30 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -389,8 +389,10 @@ PathSet Store::queryValidPaths(const PathSet & paths, SubstituteFlag maybeSubsti Sync<State> state_(State{paths.size(), PathSet()}); std::condition_variable wakeup; + ThreadPool pool; - for (auto & path : paths) + auto doQuery = [&](const Path & path ) { + checkInterrupt(); queryPathInfo(path, [path, &state_, &wakeup](ref<ValidPathInfo> info) { auto state(state_.lock()); @@ -411,6 +413,12 @@ PathSet Store::queryValidPaths(const PathSet & paths, SubstituteFlag maybeSubsti if (!--state->left) wakeup.notify_one(); }); + }; + + for (auto & path : paths) + pool.enqueue(std::bind(doQuery, path)); + + pool.process(); while (true) { auto state(state_.lock()); |