SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
activeModule.cpp
1#include "activeModule.hpp"
2
3namespace Module {
4
5void ActiveModule_t::_runner(ActiveModule_t *m) {
6 Log.d(ID, "Starting thread", m->id);
7 m->run();
8 Log.d(ID, "Thread stopped", m->id);
9};
10
11void ActiveModule_t::start() {
12 std::lock_guard<std::mutex> lock(vMux);
13 if (threadID == -1) {
14 threadID = Thread::addThread((Thread::ThreadFunction)_runner, (void *)this, stackSize, 0);
15 if (threadID == -1) {
16 Log.f(ID, "Failed to start thread", id);
17 }
18 }
19}
20
21void ActiveModule_t::stop() {
22 std::lock_guard<std::mutex> lock(vMux);
23 if (threadID != -1) {
24 Thread::kill(threadID);
25 Thread::wait(threadID);
26 threadID = -1;
27 }
28}
29
30} // namespace Module
Logging::Log_t Log
The global logging object.
void d(LOG_TAG TAG, LOG_MSG message)
Log a string using a debug tag.
void f(LOG_TAG TAG, LOG_MSG message)
Log a string using a fatal tag.