* keybindmgr: avoid uint rollover on mouse keycode mouse keycode is 0, and the switch case checks for 0 - 8 and rolls over, just return early if keycode is 0. * watchdog: avoid data races in watchdog asan thread sanitizer reported data races in the watchdog from reading and setting the bool variables make them std::atomic bools. also add a atomic bool for the main thread to wait for to avoid data race when reading the config values. * hyprdebug: change non unicode character to name asan created false positives and didnt like this bit, so for the sake of easier debugging rename it to something unicode.
34 lines
No EOL
1 KiB
C++
34 lines
No EOL
1 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <chrono>
|
|
#include <thread>
|
|
#include <condition_variable>
|
|
|
|
class CWatchdog {
|
|
public:
|
|
// must be called from the main thread
|
|
CWatchdog();
|
|
~CWatchdog();
|
|
|
|
void startWatching();
|
|
void endWatching();
|
|
|
|
std::atomic<bool> m_bWatchdogInitialized{false};
|
|
|
|
private:
|
|
std::chrono::high_resolution_clock::time_point m_tTriggered;
|
|
|
|
pthread_t m_iMainThreadPID = 0;
|
|
|
|
std::atomic<bool> m_bWatching = false;
|
|
std::atomic<bool> m_bWillWatch = false;
|
|
|
|
std::unique_ptr<std::thread> m_pWatchdog;
|
|
std::mutex m_mWatchdogMutex;
|
|
std::atomic<bool> m_bNotified = false;
|
|
std::atomic<bool> m_bExitThread = false;
|
|
std::condition_variable m_cvWatchdogCondition;
|
|
};
|
|
|
|
inline std::unique_ptr<CWatchdog> g_pWatchdog; |