Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / commits / b6d2ec9

sdl_runtime_compiler git · main

SDL3 game for running and compiling code at runtime

sdl3 c++ compiler dlopen cmake · first commit 2026-04-19 · last commit 2026-07-03 (3 months ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-runtime-compiler

C++ 72.3% C 26.2%
git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gz

Fix render compilemsg 2 per frame With Claude

Christian Immanuel · 2026-06-10 12:50 · b6d2ec9e7df7b834ac0dddfd1c89554cb881278d

 src/states/game_state.cpp         | 22 ++++++++++------------
 src/systems/compiler_system.cpp   | 12 ++++++++----
 src/systems/dyn_loader_system.cpp |  2 +-
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/states/game_state.cpp b/src/states/game_state.cpp
index 9b0c08b..1a3c77a 100644
--- a/src/states/game_state.cpp
+++ b/src/states/game_state.cpp
@@ -702,19 +702,17 @@ GameState::update(double dt, const GlRenderer* gl)
         _particle_sys->update(dt, particle_colliders, World::get_BoxScale());
     }
 
-    { FP_ZONE("update._compiler_sys");
-        _compiler_sys->update(_compiler);
-        if (_compiler_sys->last_compile_ok) {
-            _compiler_sys->last_compile_ok = false;
-            _level_director->record_CompileOk();
-        }
+    _compiler_sys->update(_compiler);
+    if (_compiler_sys->last_compile_ok) {
+        _compiler_sys->last_compile_ok = false;
+        _level_director->record_CompileOk();
+    }
 
-        _dyn_loader_sys->update(_compiler);
-        if (_dyn_loader_sys->last_build_ok) {
-            _dyn_loader_sys->last_build_ok = false;
-            dyn_Apply(_dyn_loader_sys->load_Objects());
-            SourceTokens::copy_File(sandbox_CanonicalPath(), sandbox_BackupPath());
-        }
+    _dyn_loader_sys->update(_compiler);
+    if (_dyn_loader_sys->last_build_ok) {
+        _dyn_loader_sys->last_build_ok = false;
+        dyn_Apply(_dyn_loader_sys->load_Objects());
+        SourceTokens::copy_File(sandbox_CanonicalPath(), sandbox_BackupPath());
     }
 
     { FP_ZONE("update._program_sys");
diff --git a/src/systems/compiler_system.cpp b/src/systems/compiler_system.cpp
index 9bedaa1..29399f7 100644
--- a/src/systems/compiler_system.cpp
+++ b/src/systems/compiler_system.cpp
@@ -80,15 +80,19 @@ CompilerSystem::run_Compile(CompilerSystem* self, std::string src)
 void
 CompilerSystem::update(Text::Handler& out)
 {
-    // Drain whatever the worker produced and render it (main thread, GL-safe).
-    DynArray<std::string> lines;
+    constexpr size_t LINES_PER_FRAME = 2;
+
+    DynArray<std::string> batch;
     {
         std::lock_guard<std::mutex> lock(_mtx);
         if (_pending.empty()) return;
-        std::swap(lines, _pending);
+        const size_t n = SDL_min(LINES_PER_FRAME, _pending.size());
+        for (size_t i = 0; i < n; ++i) batch.push_back(std::move(_pending[i]));
+        _pending.erase(_pending.begin(),
+                       _pending.begin() + static_cast<std::ptrdiff_t>(n));
     }
 
-    for (const std::string& line : lines)
+    for (const std::string& line : batch)
         push_Line(out, line);
 }
 
diff --git a/src/systems/dyn_loader_system.cpp b/src/systems/dyn_loader_system.cpp
index e429323..8cd5ede 100644
--- a/src/systems/dyn_loader_system.cpp
+++ b/src/systems/dyn_loader_system.cpp
@@ -153,7 +153,7 @@ DynLoaderSystem::load_Objects()
     }
 
     dlerror();   // clear stale error
-    _handle = dlopen(_last_so_path.c_str(), RTLD_NOW | RTLD_LOCAL);
+    _handle = dlopen(_last_so_path.c_str(), RTLD_LAZY | RTLD_LOCAL);
     if (!_handle) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "DynLoaderSystem: dlopen failed: %s", dlerror());