diff options
author | Peter Bell <peterbell10@live.co.uk> | 2022-03-08 02:44:03 (GMT) |
---|---|---|
committer | Peter Bell <peterbell10@live.co.uk> | 2022-03-08 04:49:22 (GMT) |
commit | a643af2207f8f090d2a7aefeec954fcd2725c39c (patch) | |
tree | 62b9f0dac5e2d12c73d036be6dd3eb8e100b4266 /src/graph.h | |
parent | 4bd8db1fa8287ec0b828e98a7d2bcdf3d6b1904f (diff) | |
download | Ninja-a643af2207f8f090d2a7aefeec954fcd2725c39c.zip Ninja-a643af2207f8f090d2a7aefeec954fcd2725c39c.tar.gz Ninja-a643af2207f8f090d2a7aefeec954fcd2725c39c.tar.bz2 |
Pool: sort equally-weighted edges by priority
Diffstat (limited to 'src/graph.h')
-rw-r--r-- | src/graph.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/graph.h b/src/graph.h index 728cdc8..4fc34ca 100644 --- a/src/graph.h +++ b/src/graph.h @@ -384,14 +384,14 @@ struct DependencyScan { DyndepLoader dyndep_loader_; }; -// Implements a less comarison for edges by priority, where highest +// Implements a less comparison for edges by priority, where highest // priority is defined lexicographically first by largest critical // time, then lowest ID. // // Including ID means that wherever the critical times are the same, // the edges are executed in ascending ID order which was historically // how all tasks were scheduled. -struct EdgePriorityCompare { +struct EdgePriorityLess { bool operator()(const Edge* e1, const Edge* e2) const { const int64_t ct1 = e1->critical_time(); const int64_t ct2 = e2->critical_time(); @@ -402,11 +402,18 @@ struct EdgePriorityCompare { } }; +// Reverse of EdgePriorityLess, e.g. to sort by highest priority first +struct EdgePriorityGreater { + bool operator()(const Edge* e1, const Edge* e2) const { + return EdgePriorityLess()(e2, e1); + } +}; + // A priority queue holding non-owning Edge pointers. top() will // return the edge with the largest critical time, and lowest ID if // more than one edge has the same critical time. class EdgePriorityQueue: - public std::priority_queue<Edge*, std::vector<Edge*>, EdgePriorityCompare>{ + public std::priority_queue<Edge*, std::vector<Edge*>, EdgePriorityLess>{ public: void clear() { c.clear(); |