-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputation.cpp
More file actions
executable file
·56 lines (43 loc) · 1.09 KB
/
Computation.cpp
File metadata and controls
executable file
·56 lines (43 loc) · 1.09 KB
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
/*
* Computation.cpp
*
* Created on: Nov 11, 2019
* Author: joseph
*/
#include "Computation.h"
Computation::Computation(int loopOneStart, int loopOneEnd, int loopTwoStart, int loopTwoEnd, QueueHandle_t &refParamQueue) {
this->loopOneStart = loopOneStart;
this->loopOneEnd = loopOneEnd;
this->loopTwoStart = loopTwoStart;
this->loopTwoEnd = loopTwoEnd;
queue = new QueueHandle_t();
*queue = refParamQueue;
}
Computation::~Computation() {
// TODO Auto-generated destructor stub
}
int Computation::getLoopOneEnd() {
return loopOneEnd;
}
int Computation::getLoopOneStart() {
return loopOneStart;
}
int Computation::getLoopTwoEnd() {
return loopTwoEnd;
}
int Computation::getLoopTwoStart() {
return loopTwoStart;
}
void Computation::compute() {
long count = 0;
for (int i = getLoopOneStart(); i < getLoopOneEnd(); i++) {
for (int j = getLoopTwoStart(); j < getLoopTwoEnd(); j++) {
count += i * j;
}
}
/*
* push back the result to the receiver of the queue
* "he" is actually waiting for the result until its transmitted
*/
xQueueSend(*queue, &count, portMAX_DELAY);
}