mirror of https://github.com/FOME-Tech/fome-fw.git
don't fail on multiple Start calls (#1396)
Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
8d670c59ca
commit
a26355fdd1
|
@ -25,6 +25,7 @@ class ThreadController : public ControllerBase
|
||||||
private:
|
private:
|
||||||
THD_WORKING_AREA(m_threadstack, TStackSize);
|
THD_WORKING_AREA(m_threadstack, TStackSize);
|
||||||
const tprio_t m_prio;
|
const tprio_t m_prio;
|
||||||
|
bool m_isStarted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The OS can only call a function with a single void* param. We have
|
* The OS can only call a function with a single void* param. We have
|
||||||
|
@ -57,8 +58,14 @@ public:
|
||||||
*/
|
*/
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
if (m_isStarted) {
|
||||||
|
warning(CUSTOM_OBD_6003, "Tried to start thread %s but it was already running", GetName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_thread = chThdCreateStatic(m_threadstack, sizeof(m_threadstack), m_prio, StaticThreadTaskAdapter, this);
|
m_thread = chThdCreateStatic(m_threadstack, sizeof(m_threadstack), m_prio, StaticThreadTaskAdapter, this);
|
||||||
m_thread->name = GetName();
|
m_thread->name = GetName();
|
||||||
|
m_isStarted = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue