Use yield() where possible

Replaced calls of this_thread::sleep_* with this_thread::yield(), which
yields the thread to the OS' scheduler.
This commit is contained in:
Lion Kortlepel
2022-02-03 18:57:52 +01:00
parent 29f8d29e33
commit 754053e73f
4 changed files with 18 additions and 23 deletions

View File

@@ -386,7 +386,7 @@ TConsole::TConsole() {
} else {
auto Future = mLuaEngine->EnqueueScript(mStateId, { std::make_shared<std::string>(cmd), "", "" });
while (!Future->Ready) {
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // TODO: Add a timeout
std::this_thread::yield(); // TODO: Add a timeout
}
if (Future->Error) {
beammp_lua_error(Future->ErrorMessage);