mirror of
https://github.com/NixOS/nix
synced 2025-07-07 10:11:47 +02:00
Get rid of on usage pair of actLock
Now that we have coroutines, we can go back to loops and regular RAII, which is must less error-proone! I look forward to removing the other instances!
This commit is contained in:
parent
7f8d348f3d
commit
1c022077ea
1 changed files with 10 additions and 8 deletions
|
@ -594,17 +594,19 @@ Goal::Co DerivationGoal::tryToBuild()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!outputLocks.lockPaths(lockFiles, "", false)) {
|
if (!outputLocks.lockPaths(lockFiles, "", false))
|
||||||
if (!actLock)
|
{
|
||||||
actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting,
|
Activity act(*logger, lvlWarn, actBuildWaiting,
|
||||||
fmt("waiting for lock on %s", Magenta(showPaths(lockFiles))));
|
fmt("waiting for lock on %s", Magenta(showPaths(lockFiles))));
|
||||||
|
|
||||||
|
/* Wait then try locking again, repeat until success (returned
|
||||||
|
boolean is true). */
|
||||||
|
do {
|
||||||
worker.waitForAWhile(shared_from_this());
|
worker.waitForAWhile(shared_from_this());
|
||||||
co_await Suspend{};
|
co_await Suspend{};
|
||||||
co_return tryToBuild();
|
} while (!outputLocks.lockPaths(lockFiles, "", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
actLock.reset();
|
|
||||||
|
|
||||||
/* Now check again whether the outputs are valid. This is because
|
/* Now check again whether the outputs are valid. This is because
|
||||||
another process may have started building in parallel. After
|
another process may have started building in parallel. After
|
||||||
it has finished and released the locks, we can (and should)
|
it has finished and released the locks, we can (and should)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue