mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
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>
This commit is contained in:
parent
8a6cf4fad6
commit
4b9d14378f
5 changed files with 17 additions and 27 deletions
|
@ -2041,8 +2041,7 @@ void DerivationGoal::startBuilder()
|
||||||
/* parent */
|
/* parent */
|
||||||
pid.setSeparatePG(true);
|
pid.setSeparatePG(true);
|
||||||
builderOut.writeSide.close();
|
builderOut.writeSide.close();
|
||||||
worker.childStarted(shared_from_this(), pid,
|
worker.childStarted(shared_from_this(), pid, std::set<int>{builderOut.readSide}, true, true);
|
||||||
singleton<set<int> >(builderOut.readSide), true, true);
|
|
||||||
|
|
||||||
/* Check if setting up the build environment failed. */
|
/* Check if setting up the build environment failed. */
|
||||||
string msg = readLine(builderOut.readSide);
|
string msg = readLine(builderOut.readSide);
|
||||||
|
@ -3168,7 +3167,7 @@ void SubstitutionGoal::tryNext()
|
||||||
trace("trying substituter");
|
trace("trying substituter");
|
||||||
|
|
||||||
SubstitutablePathInfos infos;
|
SubstitutablePathInfos infos;
|
||||||
PathSet dummy(singleton<PathSet>(storePath));
|
PathSet dummy{storePath};
|
||||||
worker.store.querySubstitutablePathInfos(dummy, infos);
|
worker.store.querySubstitutablePathInfos(dummy, infos);
|
||||||
SubstitutablePathInfos::iterator k = infos.find(storePath);
|
SubstitutablePathInfos::iterator k = infos.find(storePath);
|
||||||
if (k == infos.end()) {
|
if (k == infos.end()) {
|
||||||
|
@ -3243,7 +3242,7 @@ void SubstitutionGoal::tryToRun()
|
||||||
|
|
||||||
/* Acquire a lock on the output path. */
|
/* Acquire a lock on the output path. */
|
||||||
outputLock = std::shared_ptr<PathLocks>(new PathLocks);
|
outputLock = std::shared_ptr<PathLocks>(new PathLocks);
|
||||||
if (!outputLock->lockPaths(singleton<PathSet>(storePath), "", false)) {
|
if (!outputLock->lockPaths(PathSet{storePath}, "", false)) {
|
||||||
worker.waitForAWhile(shared_from_this());
|
worker.waitForAWhile(shared_from_this());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3842,7 +3841,7 @@ void LocalStore::ensurePath(const Path & path)
|
||||||
|
|
||||||
Worker worker(*this);
|
Worker worker(*this);
|
||||||
GoalPtr goal = worker.makeSubstitutionGoal(path);
|
GoalPtr goal = worker.makeSubstitutionGoal(path);
|
||||||
Goals goals = singleton<Goals>(goal);
|
Goals goals{goal};
|
||||||
|
|
||||||
worker.run(goals);
|
worker.run(goals);
|
||||||
|
|
||||||
|
@ -3855,7 +3854,7 @@ void LocalStore::repairPath(const Path & path)
|
||||||
{
|
{
|
||||||
Worker worker(*this);
|
Worker worker(*this);
|
||||||
GoalPtr goal = worker.makeSubstitutionGoal(path, true);
|
GoalPtr goal = worker.makeSubstitutionGoal(path, true);
|
||||||
Goals goals = singleton<Goals>(goal);
|
Goals goals{goal};
|
||||||
|
|
||||||
worker.run(goals);
|
worker.run(goals);
|
||||||
|
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name,
|
||||||
/* The first check above is an optimisation to prevent
|
/* The first check above is an optimisation to prevent
|
||||||
unnecessary lock acquisition. */
|
unnecessary lock acquisition. */
|
||||||
|
|
||||||
PathLocks outputLock(singleton<PathSet, Path>(dstPath));
|
PathLocks outputLock{ PathSet{dstPath} };
|
||||||
|
|
||||||
if (repair || !isValidPath(dstPath)) {
|
if (repair || !isValidPath(dstPath)) {
|
||||||
|
|
||||||
|
@ -1084,7 +1084,7 @@ Path LocalStore::addTextToStore(const string & name, const string & s,
|
||||||
|
|
||||||
if (repair || !isValidPath(dstPath)) {
|
if (repair || !isValidPath(dstPath)) {
|
||||||
|
|
||||||
PathLocks outputLock(singleton<PathSet, Path>(dstPath));
|
PathLocks outputLock{ PathSet{dstPath} };
|
||||||
|
|
||||||
if (repair || !isValidPath(dstPath)) {
|
if (repair || !isValidPath(dstPath)) {
|
||||||
|
|
||||||
|
@ -1380,7 +1380,7 @@ Path LocalStore::importPath(bool requireSignature, Source & source)
|
||||||
lock on this path). */
|
lock on this path). */
|
||||||
Strings locksHeld = tokenizeString<Strings>(getEnv("NIX_HELD_LOCKS"));
|
Strings locksHeld = tokenizeString<Strings>(getEnv("NIX_HELD_LOCKS"));
|
||||||
if (find(locksHeld.begin(), locksHeld.end(), dstPath) == locksHeld.end())
|
if (find(locksHeld.begin(), locksHeld.end(), dstPath) == locksHeld.end())
|
||||||
outputLock.lockPaths(singleton<PathSet, Path>(dstPath));
|
outputLock.lockPaths(PathSet{dstPath});
|
||||||
|
|
||||||
if (!isValidPath(dstPath)) {
|
if (!isValidPath(dstPath)) {
|
||||||
|
|
||||||
|
|
|
@ -76,24 +76,24 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef list<string> Strings;
|
using Strings = std::list<std::string>;
|
||||||
typedef set<string> StringSet;
|
using StringSet = std::set<std::string>;
|
||||||
|
|
||||||
|
|
||||||
/* Paths are just strings. */
|
/* Paths are just strings. */
|
||||||
typedef string Path;
|
using Path = std::string;
|
||||||
typedef list<Path> Paths;
|
using Paths = std::list<Path>;
|
||||||
typedef set<Path> PathSet;
|
using PathSet = std::set<Path>;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
enum Verbosity {
|
||||||
lvlError = 0,
|
lvlError = 0,
|
||||||
lvlInfo,
|
lvlInfo,
|
||||||
lvlTalkative,
|
lvlTalkative,
|
||||||
lvlChatty,
|
lvlChatty,
|
||||||
lvlDebug,
|
lvlDebug,
|
||||||
lvlVomit
|
lvlVomit
|
||||||
} Verbosity;
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,15 +121,6 @@ Paths createDirs(const Path & path);
|
||||||
void createSymlink(const Path & target, const Path & link);
|
void createSymlink(const Path & target, const Path & link);
|
||||||
|
|
||||||
|
|
||||||
template<class T, class A>
|
|
||||||
T singleton(const A & a)
|
|
||||||
{
|
|
||||||
T t;
|
|
||||||
t.insert(a);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Messages. */
|
/* Messages. */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,7 @@ static void performOp(bool trusted, unsigned int clientVersion,
|
||||||
case wopHasSubstitutes: {
|
case wopHasSubstitutes: {
|
||||||
Path path = readStorePath(from);
|
Path path = readStorePath(from);
|
||||||
startWork();
|
startWork();
|
||||||
PathSet res = store->querySubstitutablePaths(singleton<PathSet>(path));
|
PathSet res = store->querySubstitutablePaths(PathSet{path});
|
||||||
stopWork();
|
stopWork();
|
||||||
writeInt(res.find(path) != res.end(), to);
|
writeInt(res.find(path) != res.end(), to);
|
||||||
break;
|
break;
|
||||||
|
@ -656,7 +656,7 @@ static void performOp(bool trusted, unsigned int clientVersion,
|
||||||
Path path = absPath(readString(from));
|
Path path = absPath(readString(from));
|
||||||
startWork();
|
startWork();
|
||||||
SubstitutablePathInfos infos;
|
SubstitutablePathInfos infos;
|
||||||
store->querySubstitutablePathInfos(singleton<PathSet>(path), infos);
|
store->querySubstitutablePathInfos(PathSet{path}, infos);
|
||||||
stopWork();
|
stopWork();
|
||||||
SubstitutablePathInfos::iterator i = infos.find(path);
|
SubstitutablePathInfos::iterator i = infos.find(path);
|
||||||
if (i == infos.end())
|
if (i == infos.end())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue