coroutine: wip

This commit is contained in:
Kevin Hester
2020-10-09 09:10:44 +08:00
parent bed7d8a619
commit dd6a402ea0
18 changed files with 73 additions and 436 deletions

View File

@@ -1,17 +1,39 @@
#pragma once
#include "FreeRtosThread.h"
#include "PosixThread.h"
#include <cstdlib>
#include <stdint.h>
#include "Thread.h"
#include "freertosinc.h"
namespace concurrency
{
#ifdef HAS_FREE_RTOS
typedef FreeRtosThread OSThread;
#endif
/**
* @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() {}
#ifdef __unix__
typedef PosixThread OSThread;
#endif
// uint32_t getStackHighwaterMark() { return uxTaskGetStackHighWaterMark(taskHandle); }
protected:
/**
* The method that will be called each time our thread gets a chance to run
*/
virtual void runOnce() = 0;
};
} // namespace concurrency