Skip to content

Commit

Permalink
core: let the server sleep for 1ms and yield its thread during downti…
Browse files Browse the repository at this point in the history
…me to avoid busyloop
  • Loading branch information
zpl-zak committed Jan 10, 2024
1 parent ef60e0f commit 818b8f3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion code/framework/src/integrations/server/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,13 @@ namespace Framework::Integrations::Server {
_nextTick = std::chrono::high_resolution_clock::now() + std::chrono::milliseconds(static_cast<int64_t>(_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();
}
}

Expand Down

0 comments on commit 818b8f3

Please sign in to comment.