libstore: split PathLocks::lockPaths into lock, tryLock

Change-Id: I202cfc077b7e468c74ecd8039175cef34855944c
This commit is contained in:
eldritch horrors
2025-02-06 14:05:34 +00:00
parent 3b10c19006
commit 3c7162e6d0
3 changed files with 13 additions and 7 deletions
+1 -1
View File
@@ -734,7 +734,7 @@ retry:
}
}
if (!outputLocks.lockPaths(lockFiles, "", false)) {
if (!outputLocks.tryLockPaths(lockFiles)) {
if (!actLock)
actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting,
fmt("waiting for lock on %s", Magenta(showPaths(lockFiles))));
+1 -1
View File
@@ -113,7 +113,7 @@ PathLocks::PathLocks(const PathSet & paths, const std::string & waitMsg)
}
bool PathLocks::lockPaths(const PathSet & paths,
bool PathLocks::lockPathsImpl(const PathSet & paths,
const std::string & waitMsg, bool wait)
{
assert(fds.empty());
+11 -5
View File
@@ -39,13 +39,19 @@ private:
std::list<FDPair> fds;
bool deletePaths;
bool lockPathsImpl(const PathSet & _paths, const std::string & waitMsg, bool wait);
public:
PathLocks();
PathLocks(const PathSet & paths,
const std::string & waitMsg = "");
bool lockPaths(const PathSet & _paths,
const std::string & waitMsg = "",
bool wait = true);
PathLocks(const PathSet & paths, const std::string & waitMsg = "");
void lockPaths(const PathSet & _paths, const std::string & waitMsg = "")
{
lockPathsImpl(_paths, waitMsg, true);
}
bool tryLockPaths(const PathSet & _paths)
{
return lockPathsImpl(_paths, "", false);
}
~PathLocks();
void unlock();
void setDeletion(bool deletePaths);