-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject_threads.cpp
47 lines (41 loc) · 913 Bytes
/
object_threads.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
#include "proto.hpp"
#include "os.hpp"
#include <iostream>
#include <cstdint>
using std::cout;
struct MyObject : public Proto::Object
{
Proto::Thread BlinkingThread_Instance;
Proto::Thread BeepingThread_Instance;
uint32_t m_BeepCount = 0;
void Run()
{
[](Proto::Thread& rThread) {
ThreadBegin();
for (;;) {
cout << "BlinkingThread: LED On\n";
ThreadDelayMS(250);
cout << "BlinkingThread: LED Off\n";
ThreadDelayMS(750);
}
ThreadEnd();
}(BlinkingThread_Instance);
[&](Proto::Thread& rThread) {
ThreadBegin();
for (;;) {
m_BeepCount += 1;
cout << "BeepingThread: Beep " << m_BeepCount << '\n';
ThreadDelaySeconds(2);
}
ThreadEnd();
}(BeepingThread_Instance);
}
};
int main()
{
MyObject MyObject;
for (;;) {
Proto::Run();
OS::DelayMS(1);
}
}