2020-10-09 01:10:44 +00:00
|
|
|
#include "OSThread.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
namespace concurrency
|
|
|
|
{
|
|
|
|
|
2020-10-10 00:28:00 +00:00
|
|
|
ThreadController mainController, timerController;
|
|
|
|
|
|
|
|
void OSThread::setup()
|
|
|
|
{
|
|
|
|
mainController.ThreadName = "mainController";
|
|
|
|
timerController.ThreadName = "timerController";
|
|
|
|
}
|
|
|
|
|
|
|
|
OSThread::OSThread(const char *_name, uint32_t period, ThreadController *_controller)
|
|
|
|
: Thread(NULL, period), controller(_controller)
|
|
|
|
{
|
|
|
|
ThreadName = _name;
|
|
|
|
|
|
|
|
if (controller)
|
|
|
|
controller->add(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
OSThread::~OSThread()
|
|
|
|
{
|
|
|
|
if (controller)
|
|
|
|
controller->remove(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSThread::run()
|
|
|
|
{
|
|
|
|
auto newDelay = runOnce();
|
|
|
|
|
|
|
|
runned();
|
|
|
|
|
|
|
|
if (newDelay != 0)
|
|
|
|
setInterval(newDelay);
|
|
|
|
}
|
|
|
|
|
2020-10-09 01:10:44 +00:00
|
|
|
} // namespace concurrency
|