45 bool operator()(
const std::shared_ptr<ThreadMsg>& a,
const std::shared_ptr<ThreadMsg>& b)
const {
46 return static_cast<int>(a->GetPriority()) <
static_cast<int>(b->GetPriority());
60 Thread(
const std::string& threadName,
size_t maxQueueSize = 0);
69 bool CreateThread(std::optional<dmq::Duration> watchdogTimeout = std::nullopt);
96 static DWORD WINAPI ThreadProc(LPVOID lpParam);
105 void WatchdogCheck();
113 HANDLE m_hThread = NULL;
114 DWORD m_threadId = 0;
117 HANDLE m_hStartEvent = NULL;
119 CRITICAL_SECTION m_cs;
122 CONDITION_VARIABLE m_cvNotEmpty;
125 CONDITION_VARIABLE m_cvNotFull;
127 std::priority_queue<std::shared_ptr<ThreadMsg>,
128 std::vector<std::shared_ptr<ThreadMsg>>,
131 const std::string THREAD_NAME;
134 const size_t MAX_QUEUE_SIZE;
136 std::atomic<bool> m_exit;
139 std::atomic<dmq::TimePoint> m_lastAliveTime;
140 std::unique_ptr<Timer> m_watchdogTimer;
142 std::unique_ptr<Timer> m_threadTimer;
144 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
virtual ~Thread()
Destructor.
std::string GetThreadName()
Get thread name.
Definition win32/Thread.h:81
virtual void DispatchDelegate(std::shared_ptr< dmq::DelegateMsg > msg) override
DWORD GetThreadId()
Get the ID of this thread instance.
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.
void ExitThread()
Called once at program exit to shut down the worker thread.
static DWORD GetCurrentThreadId()
Get the ID of the currently executing thread.
A base class for a delegate enabled execution thread. Implemented by application code if asynchronous...
Definition IThread.h:22
RAII handle to a single Signal subscription. Disconnects automatically on destruction....
Definition Signal.h:104
Definition stdlib/Thread.h:39
bool operator()(const std::shared_ptr< ThreadMsg > &a, const std::shared_ptr< ThreadMsg > &b) const
Definition win32/Thread.h:45