forked from FOME-Tech/fome-fw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global_execution_queue.cpp
58 lines (45 loc) · 1.2 KB
/
global_execution_queue.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* global_execution_queue.cpp
*
* @date Dec 8, 2018
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "pch.h"
#include "global_execution_queue.h"
bool debugSignalExecutor = false;
TestExecutor::~TestExecutor() {
// Flush the queue and reset all scheduling_s at the end of a test's execution
clear();
}
int TestExecutor::executeAll(efitick_t now) {
return schedulingQueue.executeAll(now);
}
void TestExecutor::clear() {
schedulingQueue.clear();
}
int TestExecutor::size() {
return schedulingQueue.size();
}
scheduling_s* TestExecutor::getHead() {
return schedulingQueue.getHead();
}
scheduling_s* TestExecutor::getForUnitTest(int index) {
return schedulingQueue.getElementAtIndexForUnitText(index);
}
void TestExecutor::schedule(const char *msg, scheduling_s* scheduling, efitick_t timeNt, action_s action) {
if (m_mockExecutor) {
m_mockExecutor->schedule(msg, scheduling, timeNt, action);
return;
}
schedulingQueue.insertTask(scheduling, NT2US(timeNt), action);
}
void TestExecutor::cancel(scheduling_s* s) {
if (m_mockExecutor) {
m_mockExecutor->cancel(s);
return;
}
schedulingQueue.remove(s);
}
void TestExecutor::setMockExecutor(Scheduler* exec) {
m_mockExecutor = exec;
}