From 1c2550a2ae826c422cf6d34f1c5c3e687474929d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 30 Mar 2014 00:49:23 +0100 Subject: boost::shared_ptr -> std::shared_ptr --- src/libstore/build.cc | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'src/libstore/build.cc') diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 5c3307507adc..b3d2796d813c 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -12,9 +12,6 @@ #include #include #include -#include -#include -#include #include #include @@ -84,19 +81,19 @@ struct HookInstance; /* A pointer to a goal. */ class Goal; -typedef boost::shared_ptr GoalPtr; -typedef boost::weak_ptr WeakGoalPtr; +typedef std::shared_ptr GoalPtr; +typedef std::weak_ptr WeakGoalPtr; /* Set of goals. */ typedef set Goals; -typedef set WeakGoals; +typedef list WeakGoals; /* A map of paths to goals (and the other way around). */ typedef map WeakGoalMap; -class Goal : public boost::enable_shared_from_this +class Goal : public std::enable_shared_from_this { public: typedef enum {ecBusy, ecSuccess, ecFailed, ecNoSubstituters, ecIncompleteClosure} ExitCode; @@ -242,7 +239,7 @@ public: LocalStore & store; - boost::shared_ptr hook; + std::shared_ptr hook; Worker(LocalStore & store); ~Worker(); @@ -300,10 +297,19 @@ public: ////////////////////////////////////////////////////////////////////// +void addToWeakGoals(WeakGoals & goals, GoalPtr p) +{ + // FIXME: necessary? + foreach (WeakGoals::iterator, i, goals) + if (i->lock() == p) return; + goals.push_back(p); +} + + void Goal::addWaitee(GoalPtr waitee) { waitees.insert(waitee); - waitee->waiters.insert(shared_from_this()); + addToWeakGoals(waitee->waiters, shared_from_this()); } @@ -329,7 +335,7 @@ void Goal::waiteeDone(GoalPtr waitee, ExitCode result) GoalPtr goal = *i; WeakGoals waiters2; foreach (WeakGoals::iterator, j, goal->waiters) - if (j->lock() != shared_from_this()) waiters2.insert(*j); + if (j->lock() != shared_from_this()) waiters2.push_back(*j); goal->waiters = waiters2; } waitees.clear(); @@ -735,7 +741,7 @@ private: Pipe builderOut; /* The build hook. */ - boost::shared_ptr hook; + std::shared_ptr hook; /* Whether we're currently doing a chroot build. */ bool useChroot; @@ -743,7 +749,7 @@ private: Path chrootRootDir; /* RAII object to delete the chroot directory. */ - boost::shared_ptr autoDelChroot; + std::shared_ptr autoDelChroot; /* All inputs that are regular files. */ PathSet regularInputPaths; @@ -1512,7 +1518,7 @@ HookReply DerivationGoal::tryBuildHook() if (!settings.useBuildHook || getEnv("NIX_BUILD_HOOK") == "") return rpDecline; if (!worker.hook) - worker.hook = boost::shared_ptr(new HookInstance); + worker.hook = std::shared_ptr(new HookInstance); /* Tell the hook about system features (beyond the system type) required from the build machine. (The hook could parse the @@ -1784,7 +1790,7 @@ void DerivationGoal::startBuilder() if (pathExists(chrootRootDir)) deletePath(chrootRootDir); /* Clean up the chroot directory automatically. */ - autoDelChroot = boost::shared_ptr(new AutoDelete(chrootRootDir)); + autoDelChroot = std::shared_ptr(new AutoDelete(chrootRootDir)); printMsg(lvlChatty, format("setting up chroot environment in `%1%'") % chrootRootDir); @@ -2557,7 +2563,7 @@ private: Pid pid; /* Lock on the store path. */ - boost::shared_ptr outputLock; + std::shared_ptr outputLock; /* Whether to try to repair a valid path. */ bool repair; @@ -2734,7 +2740,7 @@ void SubstitutionGoal::tryToRun() } /* Acquire a lock on the output path. */ - outputLock = boost::shared_ptr(new PathLocks); + outputLock = std::shared_ptr(new PathLocks); if (!outputLock->lockPaths(singleton(storePath), "", false)) { worker.waitForAWhile(shared_from_this()); return; @@ -3012,7 +3018,7 @@ void Worker::removeGoal(GoalPtr goal) void Worker::wakeUp(GoalPtr goal) { goal->trace("woken up"); - awake.insert(goal); + addToWeakGoals(awake, goal); } @@ -3070,21 +3076,21 @@ void Worker::waitForBuildSlot(GoalPtr goal) if (getNrLocalBuilds() < settings.maxBuildJobs) wakeUp(goal); /* we can do it right away */ else - wantingToBuild.insert(goal); + addToWeakGoals(wantingToBuild, goal); } void Worker::waitForAnyGoal(GoalPtr goal) { debug("wait for any goal"); - waitingForAnyGoal.insert(goal); + addToWeakGoals(waitingForAnyGoal, goal); } void Worker::waitForAWhile(GoalPtr goal) { debug("wait for a while"); - waitingForAWhile.insert(goal); + addToWeakGoals(waitingForAWhile, goal); } -- cgit 1.4.1