1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 08:31:16 +02:00

Simplify the callback mechanism

This commit is contained in:
Eelco Dolstra 2018-03-27 22:16:01 +02:00
parent 1672bcd230
commit 81ea8bd5ce
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
16 changed files with 152 additions and 180 deletions

View file

@ -33,9 +33,11 @@ void Store::computeFSClosure(const PathSet & startPaths,
state->pending++;
}
queryPathInfo(path,
[&, path](ref<ValidPathInfo> info) {
// FIXME: calls to isValidPath() should be async
queryPathInfo(path, {[&, path](std::future<ref<ValidPathInfo>> fut) {
// FIXME: calls to isValidPath() should be async
try {
auto info = fut.get();
if (flipDirection) {
@ -75,14 +77,13 @@ void Store::computeFSClosure(const PathSet & startPaths,
if (!--state->pending) done.notify_one();
}
},
[&, path](std::exception_ptr exc) {
} catch (...) {
auto state(state_.lock());
if (!state->exc) state->exc = exc;
if (!state->exc) state->exc = std::current_exception();
assert(state->pending);
if (!--state->pending) done.notify_one();
});
};
}});
};
for (auto & startPath : startPaths)