diff --git a/src/framework/core/asyncdispatcher.cpp b/src/framework/core/asyncdispatcher.cpp index e662a098aa..8f099d978f 100644 --- a/src/framework/core/asyncdispatcher.cpp +++ b/src/framework/core/asyncdispatcher.cpp @@ -29,8 +29,7 @@ void AsyncDispatcher::init(uint8_t maxThreads) if (maxThreads == 0) maxThreads = 6; - // -2 = Main Thread and Map Thread - int_fast8_t threads = std::clamp(std::thread::hardware_concurrency() - 2, 1, maxThreads); + int_fast8_t threads = std::clamp(std::thread::hardware_concurrency() - 1, 1, maxThreads); while (--threads >= 0) m_threads.emplace_back([this] { m_ioService.run(); }); } @@ -45,9 +44,8 @@ void AsyncDispatcher::stop() m_ioService.stop(); - for (std::size_t i = 0; i < m_threads.size(); i++) { - if (m_threads[i].joinable()) { - m_threads[i].join(); - } + for (auto& thread : m_threads) { + if (thread.joinable()) + thread.join(); } }; \ No newline at end of file diff --git a/src/framework/core/graphicalapplication.cpp b/src/framework/core/graphicalapplication.cpp index a82cc35c89..d98d601f87 100644 --- a/src/framework/core/graphicalapplication.cpp +++ b/src/framework/core/graphicalapplication.cpp @@ -137,10 +137,8 @@ void GraphicalApplication::run() const auto& foreground = g_drawPool.get(DrawPoolType::FOREGROUND); const auto& foreground_tile = g_drawPool.get(DrawPoolType::FOREGROUND_TILE); const auto& txt = g_drawPool.get(DrawPoolType::TEXT); - const auto& map = g_drawPool.get(DrawPoolType::MAP); - // clang c++20 dont support jthread - std::thread t1([&]() { + g_asyncDispatcher.dispatch([&] { g_eventThreadId = std::this_thread::get_id(); while (!m_stopping) { poll(); @@ -194,8 +192,6 @@ void GraphicalApplication::run() m_frameCounter.update(); } - t1.join(); - m_stopping = false; m_running = false; }