From 818b8f314652c72df9aea40e3a80da24aab1412a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Wed, 10 Jan 2024 22:49:42 +0100 Subject: [PATCH] core: let the server sleep for 1ms and yield its thread during downtime to avoid busyloop --- code/framework/src/integrations/server/instance.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/framework/src/integrations/server/instance.cpp b/code/framework/src/integrations/server/instance.cpp index 609350dc4..40113898a 100644 --- a/code/framework/src/integrations/server/instance.cpp +++ b/code/framework/src/integrations/server/instance.cpp @@ -363,12 +363,13 @@ namespace Framework::Integrations::Server { _nextTick = std::chrono::high_resolution_clock::now() + std::chrono::milliseconds(static_cast(_opts.tickInterval * 1000.0f)); } else { - std::this_thread::sleep_for(std::chrono::milliseconds(0)); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } void Instance::Run() { while (_alive) { Update(); + std::this_thread::yield(); } }