From ec7298f0c0966ee9c1b9d9cd1bbfe377ee2c25de Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 18 Feb 2025 20:54:25 +0100 Subject: [PATCH] impr: Make CLI not hang for a second after each command on Linux --- main/gui/source/messaging/linux.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main/gui/source/messaging/linux.cpp b/main/gui/source/messaging/linux.cpp index 1a35325e1..a25c0f5bc 100644 --- a/main/gui/source/messaging/linux.cpp +++ b/main/gui/source/messaging/linux.cpp @@ -42,12 +42,18 @@ namespace hex::messaging { static auto listenerThread = std::jthread([](const std::stop_token &stopToken){ std::vector buffer(0xFFFF); - while (!stopToken.stop_requested()) { + + while (true) { int result = ::read(fifo, buffer.data(), buffer.size()); if (result > 0) { EventNativeMessageReceived::post(std::vector{ buffer.begin(), buffer.begin() + result }); - } else { - std::this_thread::sleep_for(std::chrono::seconds(1)); + } + + if (stopToken.stop_requested()) + break; + + if (result <= 0) { + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } });