mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 02:32:23 +00:00
coroutine: wip
This commit is contained in:
@@ -1,17 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "FreeRtosNotifiedWorkerThread.h"
|
||||
#include "PosixNotifiedWorkerThread.h"
|
||||
#include "WorkerThread.h"
|
||||
|
||||
namespace concurrency
|
||||
namespace concurrency {
|
||||
|
||||
/**
|
||||
* @brief A worker thread that waits on a freertos notification
|
||||
*/
|
||||
class NotifiedWorkerThread : public WorkerThread
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Notify this thread so it can run
|
||||
*/
|
||||
virtual void notify(uint32_t v = 0, eNotifyAction action = eNoAction) = 0;
|
||||
|
||||
#ifdef HAS_FREE_RTOS
|
||||
typedef FreeRtosNotifiedWorkerThread NotifiedWorkerThread;
|
||||
#endif
|
||||
/**
|
||||
* Notify from an ISR
|
||||
*
|
||||
* This must be inline or IRAM_ATTR on ESP32
|
||||
*/
|
||||
virtual void notifyFromISR(BaseType_t *highPriWoken, uint32_t v = 0, eNotifyAction action = eNoAction) { notify(v, action); }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The notification that was most recently used to wake the thread. Read from loop()
|
||||
*/
|
||||
uint32_t notification = 0;
|
||||
|
||||
#ifdef __unix__
|
||||
typedef PosixNotifiedWorkerThread NotifiedWorkerThread;
|
||||
#endif
|
||||
/**
|
||||
* A method that should block execution - either waiting ona queue/mutex or a "task notification"
|
||||
*/
|
||||
virtual void block() = 0;
|
||||
};
|
||||
|
||||
} // namespace concurrency
|
||||
|
||||
Reference in New Issue
Block a user