DelegateMQ
Loading...
Searching...
No Matches
Thread.h File Reference

FreeRTOS implementation of the DelegateMQ IThread interface. More...

#include "delegate/IThread.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
#include <string>
#include <memory>

Go to the source code of this file.

Classes

class  Thread
 Cross-platform thread for any system supporting C++11 std::thread (e.g. Windows, Linux). More...
 

Detailed Description

FreeRTOS implementation of the DelegateMQ IThread interface.

See also
https://github.com/endurodave/DelegateMQ David Lafreniere, 2025.

This class provides a concrete implementation of the IThread interface using FreeRTOS primitives (Tasks and Queues). It enables DelegateMQ to dispatch asynchronous delegates to a dedicated FreeRTOS task.

Key Features:

  • Task Integration: Wraps a FreeRTOS xTaskCreate call to establish a dedicated worker loop.
  • Queue-Based Dispatch: Uses a FreeRTOS QueueHandle_t to receive and process incoming delegate messages in a thread-safe manner.
  • Thread Identification: Implements GetThreadId() using TaskHandle_t to ensure correct thread context checks (used by AsyncInvoke optimizations).
  • Graceful Shutdown: Provides mechanisms (ExitThread) to cleanup resources, though typical embedded tasks often run forever.