14#include <condition_variable>
20 bool operator()(
const std::shared_ptr<ThreadMsg>& a,
const std::shared_ptr<ThreadMsg>& b)
const {
21 return static_cast<int>(a->GetPriority()) <
static_cast<int>(b->GetPriority());
44 Thread(
const std::string& threadName);
53 bool CreateThread(std::optional<dmq::Duration> watchdogTimeout = std::nullopt);
82 void SetThreadName(std::thread::native_handle_type handle,
const std::string& name);
96 std::unique_ptr<std::thread> m_thread;
97 std::priority_queue<std::shared_ptr<ThreadMsg>,
98 std::vector<std::shared_ptr<ThreadMsg>>,
101 std::condition_variable m_cv;
102 const std::string THREAD_NAME;
105 std::promise<void> m_threadStartPromise;
106 std::future<void> m_threadStartFuture;
108 std::atomic<bool> m_exit;
111 std::atomic<dmq::Duration> m_lastAliveTime;
112 std::unique_ptr<Timer> m_watchdogTimer;
113 std::unique_ptr<Timer> m_threadTimer;
114 std::atomic<dmq::Duration> m_watchdogTimeout;
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 stdlib/Thread.h:65
Thread(const std::string &threadName)
Constructor.
virtual void DispatchDelegate(std::shared_ptr< dmq::DelegateMsg > msg)
std::thread::id GetThreadId()
Get the ID of this thread instance.
static std::thread::id GetCurrentThreadId()
Get the ID of the currently executing thread.
bool CreateThread()
Definition freertos/Thread.cpp:28
size_t GetQueueSize()
Get size of thread message queue.
Definition stdlib/Thread.cpp:95
void ExitThread()
Called once at program exit to shut down the worker thread.
Definition stdlib/Thread.cpp:120
Definition stdlib/Thread.h:19
bool operator()(const std::shared_ptr< ThreadMsg > &a, const std::shared_ptr< ThreadMsg > &b) const
Definition stdlib/Thread.h:20