2020-07-05 21:11:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-10-09 01:10:44 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "Thread.h"
|
|
|
|
#include "freertosinc.h"
|
2020-07-05 21:11:40 +00:00
|
|
|
|
2020-09-04 22:03:22 +00:00
|
|
|
namespace concurrency
|
2020-07-05 21:11:40 +00:00
|
|
|
{
|
2020-07-06 19:53:10 +00:00
|
|
|
|
2020-10-09 01:10:44 +00:00
|
|
|
/**
|
|
|
|
* @brief Base threading
|
|
|
|
*
|
|
|
|
* TODO FIXME @geeksville
|
|
|
|
* basic functionality
|
|
|
|
* sleeping the correct amount of time in main
|
|
|
|
* NotifiedWorkerThread set/clears enabled
|
|
|
|
*
|
|
|
|
* stopping sleep instantly as soon as an event occurs.
|
|
|
|
* use global functions delayTillWakeEvent(time), doWakeEvent(isInISR) - use freertos mutex or somesuch
|
|
|
|
*
|
|
|
|
* remove lock/lockguard
|
|
|
|
*/
|
|
|
|
class OSThread
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~OSThread() {}
|
|
|
|
|
|
|
|
// uint32_t getStackHighwaterMark() { return uxTaskGetStackHighWaterMark(taskHandle); }
|
2020-07-05 21:11:40 +00:00
|
|
|
|
2020-10-09 01:10:44 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* The method that will be called each time our thread gets a chance to run
|
|
|
|
*/
|
|
|
|
virtual void runOnce() = 0;
|
|
|
|
};
|
2020-07-06 19:53:10 +00:00
|
|
|
|
2020-07-05 21:11:40 +00:00
|
|
|
} // namespace concurrency
|