summaryrefslogtreecommitdiff
path: root/src/managers/ThreadManager.cpp
blob: fa3d0d4ef5caba0ab65a1c07ab3d8cf024242792 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#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() {
    //
}

int slowUpdate = 0;

void CThreadManager::handle() {

    g_pConfigManager->init();

    HyprCtl::startHyprCtlSocket();

    while (3.1415f) {
        slowUpdate++;
        if (slowUpdate >= g_pConfigManager->getInt("general:max_fps")){
            g_pConfigManager->tick();
            slowUpdate = 0;
        }

        std::this_thread::sleep_for(std::chrono::microseconds(1000000 / g_pConfigManager->getInt("general:max_fps")));
    }
}