feat: start loading some stuff async

This commit is contained in:
2026-10-24 01:29:00 +02:00
parent 9c5a97cfbd
commit aa3eef259c
6 changed files with 53 additions and 8 deletions
+19
View File
@@ -1,9 +1,12 @@
#include <atomic>
#include <chrono>
#include <filesystem>
#include <fstream>
#include <stdexcept>
#include <thread>
#include <vector>
#include <destrum/Serialization/SceneSerializer.h>
#include <destrum/Threading/JobSystem.h>
#include "TestUtils.h"
@@ -143,6 +146,21 @@ namespace {
check(!Jobs().IsRunning(), "job system should be stopped");
}
void testLoadSceneFileAsync()
{
Jobs().Init(2);
const auto path = std::filesystem::temp_directory_path() / "destrum_async_scene.json";
std::ofstream{path} << R"({"version":2,"name":"async","objects":[]})";
auto good = SceneSerializer::LoadSceneFileAsync(path);
auto missing = SceneSerializer::LoadSceneFileAsync(path.parent_path() / "destrum_no_such_scene.json");
check(good.get().success, "async scene load should parse a valid file");
check(!missing.get().success, "async scene load should report a missing file");
std::filesystem::remove(path);
Jobs().Shutdown();
}
void testRunsInlineWhenStopped()
{
check(!Jobs().IsRunning(), "job system should start stopped");
@@ -164,4 +182,5 @@ void RunJobsTests()
testAsyncRethrows();
testMainThreadQueue();
testShutdownDrainsPendingJobs();
testLoadSceneFileAsync();
}