16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 09:19:18 +02:00

New Components/ Prepare to new scene loading system

This commit is contained in:
2026-06-16 21:33:29 +02:00
parent 2c599cb419
commit cb739365b4
15 changed files with 712 additions and 57 deletions

View File

@@ -11,6 +11,10 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/parser.h"
#include "scene/scene.h"
#include "utilities/AsyncFilePreloader.h"
#include <thread>
#include <atomic>
namespace simulation {
@@ -23,8 +27,23 @@ struct deserializer_state {
std::string,
deserializefunctionbind> functionmap;
// background thread that scans the scenario ahead of the main parse and
// queues model files for asynchronous disk preloading
std::thread prefetch_thread;
std::atomic<bool> prefetch_cancel { false };
deserializer_state(std::string const &File, cParser::buffertype const Type, const std::string &Path, bool const Loadtraction)
: scenariofile(File), input(File, Type, Path, Loadtraction) { }
~deserializer_state() {
// safety net for the aborted-load path; on success deserialize_continue
// has already joined and stopped the preloader (idempotent here)
prefetch_cancel = true;
if (prefetch_thread.joinable())
prefetch_thread.join();
GModelPreloader.stop();
GModelPreloader.clear();
}
};
class state_serializer {