34#include <condition_variable>
40 bool operator()(
const std::shared_ptr<ThreadMsg>& a,
const std::shared_ptr<ThreadMsg>& b)
const {
41 return static_cast<int>(a->GetPriority()) <
static_cast<int>(b->GetPriority());
55 Thread(
const std::string& threadName,
size_t maxQueueSize = 0);
64 bool CreateThread(std::optional<dmq::Duration> watchdogTimeout = std::nullopt);
93 void SetThreadName(std::thread::native_handle_type handle,
const std::string& name);
107 std::unique_ptr<std::thread> m_thread;
108 std::priority_queue<std::shared_ptr<ThreadMsg>,
109 std::vector<std::shared_ptr<ThreadMsg>>,
112 std::condition_variable m_cv;
115 std::condition_variable m_cvNotFull;
117 const std::string THREAD_NAME;
120 const size_t MAX_QUEUE_SIZE;
123 std::promise<void> m_threadStartPromise;
124 std::future<void> m_threadStartFuture;
126 std::atomic<bool> m_exit;
129 std::atomic<dmq::TimePoint> m_lastAliveTime;
130 std::unique_ptr<Timer> m_watchdogTimer;
132 std::unique_ptr<Timer> m_threadTimer;
134 std::atomic<dmq::Duration> m_watchdogTimeout;
Interface for cross-thread delegate dispatching.
Cross-platform thread for any system supporting C++11 std::thread (e.g. Windows, Linux).
Definition cmsis-rtos2/Thread.h:33
std::string GetThreadName()
Get thread name.
Definition stdlib/Thread.h:76
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 cmsis-rtos2/Thread.cpp:42
Thread(const std::string &threadName, size_t maxQueueSize=0)
size_t GetQueueSize()
Get size of thread message queue.
Definition stdlib/Thread.cpp:99
void ExitThread()
Called once at program exit to shut down the worker thread.
A base class for a delegate enabled execution thread. Implemented by application code if asynchronous...
Definition IThread.h:22
RAII wrapper for Connection. Automatically disconnects when it goes out of scope.
Definition Signal.h:89
Definition stdlib/Thread.h:39
bool operator()(const std::shared_ptr< ThreadMsg > &a, const std::shared_ptr< ThreadMsg > &b) const
Definition stdlib/Thread.h:40