mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
fix cmd reader blocking main thread
This commit is contained in:
parent
7f4878e2b6
commit
019fe68b48
3 changed files with 22 additions and 1 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "logic/CommandsInterpreter.hpp"
|
||||
#include "coders/json.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
#include "util/platform.hpp"
|
||||
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
|
|
@ -18,7 +19,12 @@ void cmd::start_stdin_cmd_reader(Engine& engine) {
|
|||
logger.info() << "reader thread started";
|
||||
|
||||
std::string line;
|
||||
while (std::getline(std::cin, line)) {
|
||||
while (true) {
|
||||
if (!platform::stdin_has_data()) {
|
||||
platform::sleep(10);
|
||||
continue;
|
||||
}
|
||||
std::getline(std::cin, line);
|
||||
if (line.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue