diff options
author | Robert Iannucci <robbie@rail.com> | 2012-10-03 23:27:27 (GMT) |
---|---|---|
committer | Robert A Iannucci Jr <iannucci@chromium.org> | 2012-11-09 04:25:39 (GMT) |
commit | aca4ec54656057e58ca7a9ae5de7f94c869b2ccb (patch) | |
tree | 4dc557e0df2399092aa6e782f86dae7aa72895a0 /src/state.h | |
parent | a4220cdcd298cb43133c241497f2edb9e5cbc8d9 (diff) | |
download | Ninja-aca4ec54656057e58ca7a9ae5de7f94c869b2ccb.zip Ninja-aca4ec54656057e58ca7a9ae5de7f94c869b2ccb.tar.gz Ninja-aca4ec54656057e58ca7a9ae5de7f94c869b2ccb.tar.bz2 |
stub out an api and de-constify Pool
Diffstat (limited to 'src/state.h')
-rw-r--r-- | src/state.h | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/state.h b/src/state.h index e678df9..3e569cf 100644 --- a/src/state.h +++ b/src/state.h @@ -16,6 +16,8 @@ #define NINJA_STATE_H_ #include <map> +#include <queue> +#include <set> #include <string> #include <vector> using namespace std; @@ -37,26 +39,46 @@ struct Pool { int depth() const { return depth_; } const string& name() const { return name_; } + /// true if the Pool would delay this edge + bool ShouldDelayEdge(Edge* edge); + + /// informs this Pool that the given edge is committed to be run. + /// Pool will count this edge as using resources from this pool. + void EdgeScheduled(Edge* edge); + + /// informs this Pool that the given edge is no longer runnable, and should + /// relinquish it's resources back to the pool + void EdgeFinished(Edge* edge); + + /// adds the given edge to this Pool to be delayed. + void DelayEdge(Edge* edge); + + /// Pool will add zero or more edges to the ready_queue + void RetrieveReadyEdges(Edge* edge, set<Edge*>* ready_queue); + private: string name_; + int current_use_; int depth_; + + queue<Edge*> delayed_; }; /// Global state (file status, loaded rules) for a single run. struct State { + static Pool kDefaultPool; static const Rule kPhonyRule; - static const Pool kDefaultPool; State(); void AddRule(const Rule* rule); const Rule* LookupRule(const string& rule_name); - void AddPool(const Pool* pool); - const Pool* LookupPool(const string& pool_name); + void AddPool(Pool* pool); + Pool* LookupPool(const string& pool_name); - Edge* AddEdge(const Rule* rule, const Pool* pool); + Edge* AddEdge(const Rule* rule, Pool* pool); Node* GetNode(StringPiece path); Node* LookupNode(StringPiece path); @@ -86,7 +108,7 @@ struct State { map<string, const Rule*> rules_; /// All the pools used in the graph. - map<string, const Pool*> pools_; + map<string, Pool*> pools_; /// All the edges of the graph. vector<Edge*> edges_; |