From a1031b3af10860214dff40fa583bedcf929cbb81 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Wed, 17 Jun 2026 11:41:51 +0200 Subject: [PATCH] Use Win32 runtime binding for thread control --- docs/modernization/roadmap.md | 4 ++++ docs/modernization/tasks.md | 3 +++ src/platform_windows/windows_lifecycle_shell.cpp | 9 +++++++-- src/platform_windows/windows_runtime_shell.cpp | 6 ++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 5c72b97e..1934c9ee 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -70,6 +70,10 @@ What is already real: - `pp_app_core` Latest slice: +- `src/platform_windows/windows_runtime_shell.cpp` and + `src/platform_windows/windows_lifecycle_shell.cpp` now drive thread + start/stop through the explicit Windows runtime binding instead of routing + that control through `App::runtime()`. - `src/platform_windows/windows_platform_services.cpp` no longer brokers the Win32 main-thread queue through `bound_app()->runtime()`; it now uses an explicit Windows runtime binding. diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 517901d4..57b7bc17 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -78,6 +78,9 @@ Completed, blocked, and superseded task history moved to the queue is now ordered by code movement instead. Current slice: +- `src/platform_windows/windows_runtime_shell.cpp` and + `src/platform_windows/windows_lifecycle_shell.cpp` now use the explicit + Windows runtime binding for thread start/stop control. - `src/platform_windows/windows_platform_services.cpp` no longer uses `bound_app()->runtime()` for main-thread task brokering. - `src/platform_windows/windows_runtime_state.*` now carries the active diff --git a/src/platform_windows/windows_lifecycle_shell.cpp b/src/platform_windows/windows_lifecycle_shell.cpp index 7016a391..5d2ca47d 100644 --- a/src/platform_windows/windows_lifecycle_shell.cpp +++ b/src/platform_windows/windows_lifecycle_shell.cpp @@ -7,6 +7,7 @@ #include "platform_windows/windows_lifecycle_state.h" #include "platform_windows/windows_main_window_session.h" #include "platform_windows/windows_runtime_shell.h" +#include "platform_windows/windows_runtime_state.h" #include "platform_windows/windows_stylus_input.h" namespace pp::platform::windows { @@ -19,10 +20,14 @@ void request_window_close(HWND hWnd) void handle_window_close_message(VrShellState& vr) { auto* app = bound_app(); + auto* runtime = retained_bound_runtime(); mark_lifecycle_stopped(); request_stop_and_join_vr_thread(vr); - app->runtime().ui_thread_stop(); - app->runtime().render_thread_stop(); + if (runtime) + { + runtime->ui_thread_stop(); + runtime->render_thread_stop(); + } app->terminate(); release_bound_app(); PostQuitMessage(0); diff --git a/src/platform_windows/windows_runtime_shell.cpp b/src/platform_windows/windows_runtime_shell.cpp index 1fa10413..dd395ac1 100644 --- a/src/platform_windows/windows_runtime_shell.cpp +++ b/src/platform_windows/windows_runtime_shell.cpp @@ -30,9 +30,11 @@ void register_touch_window(HWND hWnd) void initialize_runtime_threads() { auto* app = bound_app(); + auto* runtime = retained_bound_runtime(); + assert(runtime); mark_lifecycle_running(); - app->runtime().render_thread_start(*app); - app->runtime().ui_thread_start(*app); + runtime->render_thread_start(*app); + runtime->ui_thread_start(*app); } void install_debug_gl_callbacks()