forked from lix-project/lix
Merge pull request #1632 from AmineChikhaoui/sigint-copy
run query paths in parallel during nix copy and handle SIGINT
This commit is contained in:
commit
dc30856141
|
@ -389,8 +389,10 @@ PathSet Store::queryValidPaths(const PathSet & paths, SubstituteFlag maybeSubsti
|
||||||
Sync<State> state_(State{paths.size(), PathSet()});
|
Sync<State> state_(State{paths.size(), PathSet()});
|
||||||
|
|
||||||
std::condition_variable wakeup;
|
std::condition_variable wakeup;
|
||||||
|
ThreadPool pool;
|
||||||
|
|
||||||
for (auto & path : paths)
|
auto doQuery = [&](const Path & path ) {
|
||||||
|
checkInterrupt();
|
||||||
queryPathInfo(path,
|
queryPathInfo(path,
|
||||||
[path, &state_, &wakeup](ref<ValidPathInfo> info) {
|
[path, &state_, &wakeup](ref<ValidPathInfo> info) {
|
||||||
auto state(state_.lock());
|
auto state(state_.lock());
|
||||||
|
@ -411,6 +413,12 @@ PathSet Store::queryValidPaths(const PathSet & paths, SubstituteFlag maybeSubsti
|
||||||
if (!--state->left)
|
if (!--state->left)
|
||||||
wakeup.notify_one();
|
wakeup.notify_one();
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto & path : paths)
|
||||||
|
pool.enqueue(std::bind(doQuery, path));
|
||||||
|
|
||||||
|
pool.process();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
auto state(state_.lock());
|
auto state(state_.lock());
|
||||||
|
|
Loading…
Reference in a new issue