summaryrefslogtreecommitdiffstats
path: root/src/build.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-06-20 19:17:39 (GMT)
committerBrad King <brad.king@kitware.com>2017-09-14 15:43:31 (GMT)
commitf87e865e5b4ef91ac642f063ba55708359b8294f (patch)
tree11f41e44016c48a840e54d662ea6de4ba4178f0f /src/build.h
parent87111bff382655075f2577c591745a335f0103c7 (diff)
downloadNinja-f87e865e5b4ef91ac642f063ba55708359b8294f.zip
Ninja-f87e865e5b4ef91ac642f063ba55708359b8294f.tar.gz
Ninja-f87e865e5b4ef91ac642f063ba55708359b8294f.tar.bz2
Track in Plan whether wanted edges have been scheduled
Refactor the `want_` map to track for wanted edges whether they have been scheduled or not. This gives `ScheduleWork` a direct place to keep this information, making the logic more robust and easier to follow. It also future-proofs `ScheduleWork` to avoid repeat scheduling if it is called after an edge has been removed from `ready_` by `FindWork`.
Diffstat (limited to 'src/build.h')
-rw-r--r--src/build.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/build.h b/src/build.h
index 43786f1..d7a9a79 100644
--- a/src/build.h
+++ b/src/build.h
@@ -78,17 +78,29 @@ private:
bool AddSubTarget(Node* node, Node* dependent, string* err);
void NodeFinished(Node* node);
+ /// Enumerate possible steps we want for an edge.
+ enum Want
+ {
+ /// We do not want to build the edge, but we might want to build one of
+ /// its dependents.
+ kWantNothing,
+ /// We want to build the edge, but have not yet scheduled it.
+ kWantToStart,
+ /// We want to build the edge, have scheduled it, and are waiting
+ /// for it to complete.
+ kWantToFinish
+ };
+
/// Submits a ready edge as a candidate for execution.
/// The edge may be delayed from running, for example if it's a member of a
/// currently-full pool.
- void ScheduleWork(Edge* edge);
+ void ScheduleWork(map<Edge*, Want>::iterator want_e);
/// Keep track of which edges we want to build in this plan. If this map does
/// not contain an entry for an edge, we do not want to build the entry or its
- /// dependents. If an entry maps to false, we do not want to build it, but we
- /// might want to build one of its dependents. If the entry maps to true, we
- /// want to build it.
- map<Edge*, bool> want_;
+ /// dependents. If it does contain an entry, the enumeration indicates what
+ /// we want for the edge.
+ map<Edge*, Want> want_;
set<Edge*> ready_;