Skip to content

Commit

Permalink
impr: Make CLI not hang for a second after each command on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Feb 18, 2025
1 parent a83843f commit c39ae84
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions main/gui/source/messaging/linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ namespace hex::messaging {

static auto listenerThread = std::jthread([](const std::stop_token &stopToken){
std::vector<u8> buffer(0xFFFF);
while (!stopToken.stop_requested()) {

while (true) {
int result = ::read(fifo, buffer.data(), buffer.size());
if (result > 0) {
EventNativeMessageReceived::post(std::vector<u8>{ 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));
}
}
});
Expand Down

0 comments on commit c39ae84

Please sign in to comment.