forked from lix-project/lix
Merge pull request #5106 from andir/libstore-waiter-set
libstore: use set instead of list for waiter list
This commit is contained in:
commit
873df3ab03
|
@ -13,11 +13,9 @@ bool CompareGoalPtrs::operator() (const GoalPtr & a, const GoalPtr & b) const {
|
||||||
|
|
||||||
void addToWeakGoals(WeakGoals & goals, GoalPtr p)
|
void addToWeakGoals(WeakGoals & goals, GoalPtr p)
|
||||||
{
|
{
|
||||||
// FIXME: necessary?
|
if (goals.find(p) != goals.end())
|
||||||
// FIXME: O(n)
|
return;
|
||||||
for (auto & i : goals)
|
goals.insert(p);
|
||||||
if (i.lock() == p) return;
|
|
||||||
goals.push_back(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,10 +44,7 @@ void Goal::waiteeDone(GoalPtr waitee, ExitCode result)
|
||||||
/* If we failed and keepGoing is not set, we remove all
|
/* If we failed and keepGoing is not set, we remove all
|
||||||
remaining waitees. */
|
remaining waitees. */
|
||||||
for (auto & goal : waitees) {
|
for (auto & goal : waitees) {
|
||||||
WeakGoals waiters2;
|
goal->waiters.extract(shared_from_this());
|
||||||
for (auto & j : goal->waiters)
|
|
||||||
if (j.lock() != shared_from_this()) waiters2.push_back(j);
|
|
||||||
goal->waiters = waiters2;
|
|
||||||
}
|
}
|
||||||
waitees.clear();
|
waitees.clear();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ struct CompareGoalPtrs {
|
||||||
|
|
||||||
/* Set of goals. */
|
/* Set of goals. */
|
||||||
typedef set<GoalPtr, CompareGoalPtrs> Goals;
|
typedef set<GoalPtr, CompareGoalPtrs> Goals;
|
||||||
typedef list<WeakGoalPtr> WeakGoals;
|
typedef set<WeakGoalPtr, std::owner_less<WeakGoalPtr>> WeakGoals;
|
||||||
|
|
||||||
/* A map of paths to goals (and the other way around). */
|
/* A map of paths to goals (and the other way around). */
|
||||||
typedef std::map<StorePath, WeakGoalPtr> WeakGoalMap;
|
typedef std::map<StorePath, WeakGoalPtr> WeakGoalMap;
|
||||||
|
|
Loading…
Reference in a new issue