From ed067f4a9151ba57ad2225a006b490da9ac4134f Mon Sep 17 00:00:00 2001 From: DanS Date: Fri, 9 Oct 2026 21:09:48 -0500 Subject: [PATCH] refactor(app): one idle-loop wake predicate for background results hasPendingRPCResults() becomes hasPendingBackgroundResults(): the one check the idle loop makes, every <= 200 ms, for work that finished on a background thread and still has to be applied by update(). Lanes added later put their term there. It still covers only the two RPC worker lanes; no behaviour change. Co-Authored-By: Claude Opus 5.5 --- src/app.cpp | 2 +- src/app.h | 7 +++++-- src/main.cpp | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index d6bb41c..dba3728 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -7432,7 +7432,7 @@ void App::verifyDebugCredential(const std::string& secret, std::functionhasPendingResults()) || (fast_worker_ && fast_worker_->hasPendingResults()); } diff --git a/src/app.h b/src/app.h index 08347a4..16fbc6e 100644 --- a/src/app.h +++ b/src/app.h @@ -738,8 +738,11 @@ public: bool debugGateRequiresAuth() const; void verifyDebugCredential(const std::string& secret, std::function cb); - /// @brief Check if RPC worker has queued results waiting to be processed - bool hasPendingRPCResults() const; + /// @brief Something finished on a background thread and waits for update() to apply it on the main thread + /// (the RPC worker lanes). main.cpp's idle loop polls this every <= 200 ms (hasImmediateWork) and renders a + /// frame when it is true, so the result shows without input, even while the window is hidden. A new lane whose + /// results are applied in update() adds its term HERE. + bool hasPendingBackgroundResults() const; bool hasTransactionSendProgress() const { return send_progress_active_ || send_submissions_in_flight_ > 0 || !pending_opids_.empty(); } std::string transactionSendProgressText() const; std::string transactionRefreshProgressText() const; diff --git a/src/main.cpp b/src/main.cpp index 50285f9..4d72467 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1737,9 +1737,9 @@ int main(int argc, char* argv[]) auto sinceLast = std::chrono::duration_cast( now - lastPeriodicFrame).count(); - // Immediate triggers: async RPC results, visible notifications, work in progress + // Immediate triggers: background results, visible notifications, work in progress // (also what keeps a hidden or occluded window responsive: ~5 fps while it lasts) - bool hasImmediateWork = app.hasPendingRPCResults() + bool hasImmediateWork = app.hasPendingBackgroundResults() || app.hasTransactionSendProgress() || app.isTransactionRefreshInProgress() || app.isShuttingDown()