mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-05 20:25:59 +01:00
13f6f0b923
* Migrate to hyprlang * pop up errors * fix swapped args * Meson & Nix: build with hyprlang * CI: add hyprlang to setup action * add infra for plugin stuff * fix hyprctl getoption * fix hyprctl getoption with json * format * fix post parse logic * fix autogen config * oops missed exec-once * fmt * fix ws rules * require 0.3.0 for hyprlang * nix: flaek * minor type fixes * fix cfg usages in swipe * use cvarlist for ws rules * fix throw in addPluginConfigVar * Nix: update hyprlang * minor fixes * fix disableLogs * mention hyprlang docs * bump hyprlang dep in cmake * Meson: bump min hyprlang version Nix: update hyprlang * minor fix * Nix: update meson patch --------- Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
59 lines
No EOL
1.6 KiB
C++
59 lines
No EOL
1.6 KiB
C++
#include "Watchdog.hpp"
|
|
#include <signal.h>
|
|
#include "config/ConfigManager.hpp"
|
|
|
|
CWatchdog::~CWatchdog() {
|
|
m_bExitThread = true;
|
|
m_bNotified = true;
|
|
m_cvWatchdogCondition.notify_all();
|
|
m_pWatchdog.reset();
|
|
}
|
|
|
|
CWatchdog::CWatchdog() {
|
|
m_iMainThreadPID = pthread_self();
|
|
|
|
m_pWatchdog = std::make_unique<std::thread>([this] {
|
|
static auto* const PTIMEOUT = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("debug:watchdog_timeout");
|
|
|
|
while (1337) {
|
|
std::unique_lock lk(m_mWatchdogMutex);
|
|
|
|
if (!m_bWillWatch)
|
|
m_cvWatchdogCondition.wait(lk, [this] { return m_bNotified; });
|
|
else {
|
|
if (m_cvWatchdogCondition.wait_for(lk, std::chrono::milliseconds((int)(**PTIMEOUT * 1000.0)), [this] { return m_bNotified; }) == false)
|
|
pthread_kill(m_iMainThreadPID, SIGUSR1);
|
|
}
|
|
|
|
if (m_bExitThread)
|
|
break;
|
|
|
|
m_bWatching = false;
|
|
m_bNotified = false;
|
|
}
|
|
});
|
|
|
|
m_pWatchdog->detach();
|
|
}
|
|
|
|
void CWatchdog::startWatching() {
|
|
static auto* const PTIMEOUT = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("debug:watchdog_timeout");
|
|
|
|
if (**PTIMEOUT == 0)
|
|
return;
|
|
|
|
m_tTriggered = std::chrono::high_resolution_clock::now();
|
|
m_bWillWatch = true;
|
|
m_bWatching = true;
|
|
|
|
m_bNotified = true;
|
|
m_cvWatchdogCondition.notify_all();
|
|
}
|
|
|
|
void CWatchdog::endWatching() {
|
|
m_bWatching = false;
|
|
m_bWillWatch = false;
|
|
|
|
m_bNotified = true;
|
|
m_cvWatchdogCondition.notify_all();
|
|
} |