2020-07-05 21:11:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Thread.h"
|
|
|
|
|
|
|
|
namespace concurrency {
|
|
|
|
|
|
|
|
/**
|
2020-07-05 22:54:30 +00:00
|
|
|
* @brief This wraps threading (FreeRTOS for now) with a blocking API intended for efficiently converting
|
|
|
|
* old-school arduino loop() code. Use as a mixin base class for the classes you want to convert.
|
2020-07-05 21:11:40 +00:00
|
|
|
*
|
2020-07-05 22:54:30 +00:00
|
|
|
* @link https://www.freertos.org/RTOS_Task_Notification_As_Mailbox.html
|
2020-07-05 21:11:40 +00:00
|
|
|
*/
|
|
|
|
class WorkerThread : public Thread
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* A method that should block execution - either waiting ona queue/mutex or a "task notification"
|
|
|
|
*/
|
|
|
|
virtual void block() = 0;
|
|
|
|
|
|
|
|
virtual void loop() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The method that will be called when start is called.
|
|
|
|
*/
|
|
|
|
virtual void doRun();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace concurrency
|