From e27be373781f1d755e37808a7e601a1e2049095e Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Mon, 23 Jun 2025 12:43:03 +0800 Subject: [PATCH] add mRestart flag to immediately request the thread exits to force a commit frame --- .../native/include/rendering/RenderThread.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/thermion_dart/native/include/rendering/RenderThread.hpp b/thermion_dart/native/include/rendering/RenderThread.hpp index 9e8e8de0..44bcf076 100644 --- a/thermion_dart/native/include/rendering/RenderThread.hpp +++ b/thermion_dart/native/include/rendering/RenderThread.hpp @@ -63,11 +63,22 @@ public: */ void iter(); + /** + * On emscripten builds, this breaks the current loop and + * immediately exits, yielding to the main browser loop. + * On other builds, this does nothing. + */ + void restart(); + /** * */ - bool _stop = false; + bool mStop = false; + /** + * + */ + bool mRestart = false; #ifdef __EMSCRIPTEN__ emscripten::ProxyingQueue queue; @@ -76,6 +87,7 @@ public: bool mRendered = false; bool mRender = false; + private: std::mutex _taskMutex; std::condition_variable _cv; @@ -84,6 +96,7 @@ private: int _frameCount = 0; float _accumulatedTime = 0.0f; float _fps = 0.0f; + #ifdef __EMSCRIPTEN__ pthread_t t;