DelegateMQ
Loading...
Searching...
No Matches
freertos/Thread.h
Go to the documentation of this file.
1#ifndef _THREAD_FREERTOS_H
2#define _THREAD_FREERTOS_H
3
4#include "delegate/IThread.h"
5#include "FreeRTOS.h"
6#include "task.h"
7#include "queue.h"
8
9#include <thread>
10#include <queue>
11#include <mutex>
12#include <atomic>
13#include <condition_variable>
14#include <future>
15
20
21class ThreadMsg;
22
23class Thread : public dmq::IThread
24{
25public:
27 Thread(const std::string& threadName);
28
30 ~Thread();
31
34 bool CreateThread();
35
37 TaskHandle_t GetThreadId();
38
40 static TaskHandle_t GetCurrentThreadId();
41
43 std::string GetThreadName() { return THREAD_NAME; }
44
45 virtual void DispatchDelegate(std::shared_ptr<dmq::DelegateMsg> msg);
46
47private:
48 Thread(const Thread&) = delete;
49 Thread& operator=(const Thread&) = delete;
50
52 static void Process(void*);
53
54 TaskHandle_t m_thread = nullptr;
55 QueueHandle_t m_queue = nullptr;
56
57 const std::string THREAD_NAME;
58};
59
60#endif
61
A base class for a delegate enabled execution thread. Implemented by application code if asynchronous...
Cross-platform thread for any system supporting C++11 std::thread (e.g. Windows, Linux).
Definition freertos/Thread.h:24
std::string GetThreadName()
Get thread name.
Definition freertos/Thread.h:43
Thread(const std::string &threadName)
Constructor.
Definition freertos/Thread.cpp:14
virtual void DispatchDelegate(std::shared_ptr< dmq::DelegateMsg > msg)
TaskHandle_t GetThreadId()
Get the ID of this thread instance.
Definition freertos/Thread.cpp:51
~Thread()
Destructor.
Definition freertos/Thread.cpp:21
bool CreateThread()
Definition freertos/Thread.cpp:28
static TaskHandle_t GetCurrentThreadId()
Get the ID of the currently executing thread.
Definition freertos/Thread.cpp:62
A class to hold a platform-specific thread messsage that will be passed through the OS message queue.
Definition freertos/ThreadMsg.h:7
Definition IThread.h:17