How to make user can input commands that won't block application loop. Like it is done in game servers, so admin-user can kick players, or spawn things by issuing console commands.
I have read I can make it by creating new thread for it. But if I will make, let's call it, input thread that will block with std::cin
, and then main thread will end, input thread will not join because of std::cin
is blocking.
If there is a way of killing such input thread when main thread is about to return - that would be my favorite solution. But I guess there is not such way, or if it exists, it is not to neet or safe.
Also I have read about kbhit implementation based on file descriptor set and select
function, but it doesn't work on Windows.
It would be great if the solution wouldn't need me to handle arrow, backspace, delete and shift keycodes by myself.