-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheduler.h
More file actions
26 lines (23 loc) · 783 Bytes
/
Copy pathscheduler.h
File metadata and controls
26 lines (23 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
struct Scheduler
{
std::vector<JobTuple> newEvent(
const std::vector<ResourceTuple>& resources,
const std::vector<JobTuple>& jobs);
std::vector<JobTuple> schedule();
const std::map<int, int>& nodes() const { return nodeResources; }
int unscheduledJobs() const { return sortedJobs.size(); }
private:
int findNode(int resources);
struct Comparator
{
bool operator()(const JobTuple& j1, const JobTuple& j2) const
{
return j1.resources > j2.resources ||
(j1.resources == j2.resources && (j1.timestamp < j2.timestamp ||
(j1.timestamp == j2.timestamp && j1.duration > j2.duration || (j1.duration == j2.duration && j1.id < j2.id))));
}
};
// pair: nodeId -> resources
std::map<int, int> nodeResources;
std::set<JobTuple, Comparator> sortedJobs;
};