-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheduler.cpp
More file actions
39 lines (35 loc) · 789 Bytes
/
Copy pathscheduler.cpp
File metadata and controls
39 lines (35 loc) · 789 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
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "scheduler.h"
#include <iostream>
Scheduler::Scheduler()
{
}
void Scheduler::addBot(Bot *bot)
{
m_bots.push(bot);
}
bool Scheduler::cycle()
{
m_first_start = false;
std::queue<Bot*> stepped_bots;
while(m_bots.size() > 0){
auto current_bot = m_bots.front();
m_bots.pop();
bool result = false;
try{
result = current_bot->cycle();
}catch(const std::exception& e){
std::cerr << e.what() << '\n';
delete current_bot;
continue;
}
if (result){
stepped_bots.push(current_bot);
}
}
m_bots = stepped_bots;
return m_bots.size() > 0;
}
bool Scheduler::isFirstStart()
{
return m_first_start;
}