blob: 0cac0dfa1b2d67240f9caa3d95021710779164e3 (
plain)
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
27
28
29
30
31
32
33
34
35
36
37
|
#pragma once
#include "Scheduler.h"
#include <algorithm>
namespace Simulation
{
class FirstInFirstOutScheduler : public Scheduler
{
protected:
~FirstInFirstOutScheduler()
{
}
public:
/*
Distribute workloads according to the FIFO principle
*/
void schedule(std::vector<std::reference_wrapper<Modeling::Machine>>& machines, std::vector<Workload*> workloads) override
{
if (workloads.size() == 0)
return;
// Find the first workload with dependencies finished
int index = 0;
while(!workloads.at(index)->dependencyFinished)
index = (++index) % workloads.size();
std::for_each(
machines.begin(),
machines.end(),
[index, &workloads](std::reference_wrapper<Modeling::Machine>& machine) {
machine.get().giveTask(workloads.at(index));
}
);
}
};
}
|