refactor: extract post-runnables to a separate class

This commit is contained in:
MihailRis 2024-12-25 11:04:12 +03:00
parent e98132f4da
commit 357e4f8607
3 changed files with 35 additions and 21 deletions

View file

@ -184,7 +184,7 @@ void Engine::run() {
void Engine::postUpdate() {
network->update();
processPostRunnables();
postRunnables.run();
}
void Engine::updateFrontend() {
@ -213,15 +213,6 @@ void Engine::renderFrame() {
gui->draw(ctx, *assets);
}
void Engine::processPostRunnables() {
std::lock_guard<std::recursive_mutex> lock(postRunnablesMutex);
while (!postRunnables.empty()) {
postRunnables.front()();
postRunnables.pop();
}
scripting::process_post_runnables();
}
void Engine::saveSettings() {
logger.info() << "saving settings";
files::write_string(paths.getSettingsFile(), toml::stringify(settingsHandler));
@ -517,11 +508,6 @@ std::shared_ptr<Screen> Engine::getScreen() {
return screen;
}
void Engine::postRunnable(const runnable& callback) {
std::lock_guard<std::recursive_mutex> lock(postRunnablesMutex);
postRunnables.push(callback);
}
SettingsHandler& Engine::getSettingsHandler() {
return settingsHandler;
}