Hyprland/src/managers/ThreadManager.cpp

34 lines
751 B
C++
Raw Normal View History

2022-03-18 20:03:39 +01:00
#include "ThreadManager.hpp"
2022-03-20 16:51:14 +01:00
#include "../debug/HyprCtl.hpp"
2022-03-17 15:53:45 +01:00
2022-03-18 20:03:39 +01:00
CThreadManager::CThreadManager() {
2022-03-17 20:22:29 +01:00
m_tMainThread = new std::thread([&]() {
2022-03-17 15:53:45 +01:00
// Call the handle method.
this->handle();
});
m_tMainThread->detach(); // detach and continue.
}
2022-03-18 20:03:39 +01:00
CThreadManager::~CThreadManager() {
2022-03-17 15:53:45 +01:00
//
}
2022-03-20 19:58:12 +01:00
int slowUpdate = 0;
2022-03-18 20:03:39 +01:00
void CThreadManager::handle() {
2022-03-17 17:08:54 +01:00
g_pConfigManager->init();
2022-03-21 18:29:41 +01:00
HyprCtl::startHyprCtlSocket();
2022-03-17 15:53:45 +01:00
while (3.1415f) {
2022-03-20 19:58:12 +01:00
slowUpdate++;
if (slowUpdate >= g_pConfigManager->getInt("general:max_fps")){
g_pConfigManager->tick();
slowUpdate = 0;
}
2022-03-17 15:53:45 +01:00
2022-03-20 19:58:12 +01:00
std::this_thread::sleep_for(std::chrono::microseconds(1000000 / g_pConfigManager->getInt("general:max_fps")));
2022-03-17 15:53:45 +01:00
}
}