concurrency wip

This commit is contained in:
Kevin Hester
2020-10-10 08:28:00 +08:00
parent 2044427e97
commit c46a884558
5 changed files with 88 additions and 7 deletions
+33
View File
@@ -4,4 +4,37 @@
namespace concurrency
{
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);
}
} // namespace concurrency