mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-25 14:29:49 +01:00
Make the thread manager into a wl event loop timer
This commit is contained in:
parent
189cbe9f09
commit
75ce01b1a7
2 changed files with 19 additions and 26 deletions
|
@ -1,34 +1,29 @@
|
|||
#include "ThreadManager.hpp"
|
||||
#include "../debug/HyprCtl.hpp"
|
||||
|
||||
CThreadManager::CThreadManager() {
|
||||
m_tMainThread = new std::thread([&]() {
|
||||
// Call the handle method.
|
||||
this->handle();
|
||||
});
|
||||
|
||||
m_tMainThread->detach(); // detach and continue.
|
||||
}
|
||||
|
||||
CThreadManager::~CThreadManager() {
|
||||
//
|
||||
}
|
||||
#include "../Compositor.hpp"
|
||||
|
||||
int slowUpdate = 0;
|
||||
|
||||
void CThreadManager::handle() {
|
||||
int handleTimer(void* data) {
|
||||
const auto PTM = (CThreadManager*)data;
|
||||
|
||||
g_pConfigManager->tick();
|
||||
|
||||
wl_event_source_timer_update(PTM->m_esConfigTimer, 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CThreadManager::CThreadManager() {
|
||||
g_pConfigManager->init();
|
||||
|
||||
HyprCtl::startHyprCtlSocket();
|
||||
|
||||
while (3.1415f) {
|
||||
slowUpdate++;
|
||||
if (slowUpdate >= g_pConfigManager->getInt("general:max_fps")){
|
||||
g_pConfigManager->tick();
|
||||
slowUpdate = 0;
|
||||
}
|
||||
m_esConfigTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, handleTimer, this);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(1000000 / g_pConfigManager->getInt("general:max_fps")));
|
||||
}
|
||||
wl_event_source_timer_update(m_esConfigTimer, 1000);
|
||||
}
|
||||
|
||||
CThreadManager::~CThreadManager() {
|
||||
//
|
||||
}
|
|
@ -9,11 +9,9 @@ public:
|
|||
CThreadManager();
|
||||
~CThreadManager();
|
||||
|
||||
private:
|
||||
wl_event_source* m_esConfigTimer;
|
||||
|
||||
void handle();
|
||||
|
||||
std::thread* m_tMainThread;
|
||||
private:
|
||||
};
|
||||
|
||||
inline std::unique_ptr<CThreadManager> g_pThreadManager;
|
Loading…
Reference in a new issue