diff options
| author | Congcong Kuo <congcong.kuo@gmail.com> | 2025-05-26 00:49:26 +0800 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-06-03 15:09:55 +0200 |
| commit | 4b9d14378fcc3d8dd4eea36b541fe87e198fd7b8 (patch) | |
| tree | 530ea4ad44c0c1bdd9d4c655627f7f60a8cf5c74 /nix/libstore | |
| parent | 8a6cf4fad6d6568940286adc4197f37a344d4e5a (diff) | |
daemon: Remove ‘singleton’ and replace ‘typedef’ with ‘using’ in ‘types.hh’
* nix/libutil/util.hh (singleton): Remove.
* nix/libstore/build.cc (DerivationGoal::startBuilder)
(SubstitutionGoal::tryNext, SubstitutionGoal::tryToRun)
(LocalStore::ensurePath, LocalStore::repairPath): Use normal
construction function instead of ‘singleton’.
* nix/libstore/local-store.cc (LocalStore::addToStoreFromDump)
(LocalStore::addTextToStore, LocalStore::importPath): Likewise.
* nix/nix-daemon/nix-daemon.cc (performOp): Likewise.
Change-Id: If0d929407c09482f3b506a1c51dfda70e29696dd
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'nix/libstore')
| -rw-r--r-- | nix/libstore/build.cc | 11 | ||||
| -rw-r--r-- | nix/libstore/local-store.cc | 6 |
2 files changed, 8 insertions, 9 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index 993876c6d10..47e93d1a211 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc | |||
| @@ -2041,8 +2041,7 @@ void DerivationGoal::startBuilder() | |||
| 2041 | /* parent */ | 2041 | /* parent */ |
| 2042 | pid.setSeparatePG(true); | 2042 | pid.setSeparatePG(true); |
| 2043 | builderOut.writeSide.close(); | 2043 | builderOut.writeSide.close(); |
| 2044 | worker.childStarted(shared_from_this(), pid, | 2044 | worker.childStarted(shared_from_this(), pid, std::set<int>{builderOut.readSide}, true, true); |
| 2045 | singleton<set<int> >(builderOut.readSide), true, true); | ||
| 2046 | 2045 | ||
| 2047 | /* Check if setting up the build environment failed. */ | 2046 | /* Check if setting up the build environment failed. */ |
| 2048 | string msg = readLine(builderOut.readSide); | 2047 | string msg = readLine(builderOut.readSide); |
| @@ -3168,7 +3167,7 @@ void SubstitutionGoal::tryNext() | |||
| 3168 | trace("trying substituter"); | 3167 | trace("trying substituter"); |
| 3169 | 3168 | ||
| 3170 | SubstitutablePathInfos infos; | 3169 | SubstitutablePathInfos infos; |
| 3171 | PathSet dummy(singleton<PathSet>(storePath)); | 3170 | PathSet dummy{storePath}; |
| 3172 | worker.store.querySubstitutablePathInfos(dummy, infos); | 3171 | worker.store.querySubstitutablePathInfos(dummy, infos); |
| 3173 | SubstitutablePathInfos::iterator k = infos.find(storePath); | 3172 | SubstitutablePathInfos::iterator k = infos.find(storePath); |
| 3174 | if (k == infos.end()) { | 3173 | if (k == infos.end()) { |
| @@ -3243,7 +3242,7 @@ void SubstitutionGoal::tryToRun() | |||
| 3243 | 3242 | ||
| 3244 | /* Acquire a lock on the output path. */ | 3243 | /* Acquire a lock on the output path. */ |
| 3245 | outputLock = std::shared_ptr<PathLocks>(new PathLocks); | 3244 | outputLock = std::shared_ptr<PathLocks>(new PathLocks); |
| 3246 | if (!outputLock->lockPaths(singleton<PathSet>(storePath), "", false)) { | 3245 | if (!outputLock->lockPaths(PathSet{storePath}, "", false)) { |
| 3247 | worker.waitForAWhile(shared_from_this()); | 3246 | worker.waitForAWhile(shared_from_this()); |
| 3248 | return; | 3247 | return; |
| 3249 | } | 3248 | } |
| @@ -3842,7 +3841,7 @@ void LocalStore::ensurePath(const Path & path) | |||
| 3842 | 3841 | ||
| 3843 | Worker worker(*this); | 3842 | Worker worker(*this); |
| 3844 | GoalPtr goal = worker.makeSubstitutionGoal(path); | 3843 | GoalPtr goal = worker.makeSubstitutionGoal(path); |
| 3845 | Goals goals = singleton<Goals>(goal); | 3844 | Goals goals{goal}; |
| 3846 | 3845 | ||
| 3847 | worker.run(goals); | 3846 | worker.run(goals); |
| 3848 | 3847 | ||
| @@ -3855,7 +3854,7 @@ void LocalStore::repairPath(const Path & path) | |||
| 3855 | { | 3854 | { |
| 3856 | Worker worker(*this); | 3855 | Worker worker(*this); |
| 3857 | GoalPtr goal = worker.makeSubstitutionGoal(path, true); | 3856 | GoalPtr goal = worker.makeSubstitutionGoal(path, true); |
| 3858 | Goals goals = singleton<Goals>(goal); | 3857 | Goals goals{goal}; |
| 3859 | 3858 | ||
| 3860 | worker.run(goals); | 3859 | worker.run(goals); |
| 3861 | 3860 | ||
diff --git a/nix/libstore/local-store.cc b/nix/libstore/local-store.cc index f6540c2117d..d544253add8 100644 --- a/nix/libstore/local-store.cc +++ b/nix/libstore/local-store.cc | |||
| @@ -1015,7 +1015,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name, | |||
| 1015 | /* The first check above is an optimisation to prevent | 1015 | /* The first check above is an optimisation to prevent |
| 1016 | unnecessary lock acquisition. */ | 1016 | unnecessary lock acquisition. */ |
| 1017 | 1017 | ||
| 1018 | PathLocks outputLock(singleton<PathSet, Path>(dstPath)); | 1018 | PathLocks outputLock{ PathSet{dstPath} }; |
| 1019 | 1019 | ||
| 1020 | if (repair || !isValidPath(dstPath)) { | 1020 | if (repair || !isValidPath(dstPath)) { |
| 1021 | 1021 | ||
| @@ -1084,7 +1084,7 @@ Path LocalStore::addTextToStore(const string & name, const string & s, | |||
| 1084 | 1084 | ||
| 1085 | if (repair || !isValidPath(dstPath)) { | 1085 | if (repair || !isValidPath(dstPath)) { |
| 1086 | 1086 | ||
| 1087 | PathLocks outputLock(singleton<PathSet, Path>(dstPath)); | 1087 | PathLocks outputLock{ PathSet{dstPath} }; |
| 1088 | 1088 | ||
| 1089 | if (repair || !isValidPath(dstPath)) { | 1089 | if (repair || !isValidPath(dstPath)) { |
| 1090 | 1090 | ||
| @@ -1380,7 +1380,7 @@ Path LocalStore::importPath(bool requireSignature, Source & source) | |||
| 1380 | lock on this path). */ | 1380 | lock on this path). */ |
| 1381 | Strings locksHeld = tokenizeString<Strings>(getEnv("NIX_HELD_LOCKS")); | 1381 | Strings locksHeld = tokenizeString<Strings>(getEnv("NIX_HELD_LOCKS")); |
| 1382 | if (find(locksHeld.begin(), locksHeld.end(), dstPath) == locksHeld.end()) | 1382 | if (find(locksHeld.begin(), locksHeld.end(), dstPath) == locksHeld.end()) |
| 1383 | outputLock.lockPaths(singleton<PathSet, Path>(dstPath)); | 1383 | outputLock.lockPaths(PathSet{dstPath}); |
| 1384 | 1384 | ||
| 1385 | if (!isValidPath(dstPath)) { | 1385 | if (!isValidPath(dstPath)) { |
| 1386 | 1386 | ||
