Bind Win32 main-thread queue to runtime state

This commit is contained in:
2026-06-17 11:38:43 +02:00
parent 0cf6a6ea4f
commit 9602196e99
6 changed files with 31 additions and 4 deletions

View File

@@ -70,6 +70,11 @@ What is already real:
- `pp_app_core` - `pp_app_core`
Latest slice: Latest slice:
- `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.
- `src/platform_windows/windows_runtime_state.*` now carries the active
`AppRuntime*` binding beside the retained Windows-owned runtime objects.
- `src/platform_windows/windows_runtime_state.*` now owns the retained Win32 - `src/platform_windows/windows_runtime_state.*` now owns the retained Win32
runtime object lifetime (`App`, `WacomTablet`) instead of leaving that runtime object lifetime (`App`, `WacomTablet`) instead of leaving that
storage inside `windows_runtime_shell.cpp`. storage inside `windows_runtime_shell.cpp`.

View File

@@ -78,6 +78,10 @@ Completed, blocked, and superseded task history moved to
the queue is now ordered by code movement instead. the queue is now ordered by code movement instead.
Current slice: Current slice:
- `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
`AppRuntime*` binding used by that queue hook.
- `src/platform_windows/windows_runtime_state.*` now owns the retained Win32 - `src/platform_windows/windows_runtime_state.*` now owns the retained Win32
runtime object lifetime (`App`, `WacomTablet`). runtime object lifetime (`App`, `WacomTablet`).
- `src/platform_windows/windows_runtime_shell.cpp` no longer carries that - `src/platform_windows/windows_runtime_shell.cpp` no longer carries that

View File

@@ -5,6 +5,7 @@
#include "platform_windows/windows_main_window_session.h" #include "platform_windows/windows_main_window_session.h"
#include "platform_windows/windows_platform_services.h" #include "platform_windows/windows_platform_services.h"
#include "platform_windows/windows_runtime_shell.h" #include "platform_windows/windows_runtime_shell.h"
#include "platform_windows/windows_runtime_state.h"
#include "keymap.h" #include "keymap.h"
#include "platform_windows/windows_stylus_input.h" #include "platform_windows/windows_stylus_input.h"
#include "platform_windows/windows_window_shell.h" #include "platform_windows/windows_window_shell.h"
@@ -142,9 +143,9 @@ namespace {
void enqueue_main_thread_task(std::packaged_task<void()> task) void enqueue_main_thread_task(std::packaged_task<void()> task)
{ {
if (auto* app = bound_app()) if (auto* runtime = retained_bound_runtime())
{ {
app->runtime().main_thread_task(std::move(task)); runtime->main_thread_task(std::move(task));
return; return;
} }
@@ -156,9 +157,9 @@ void enqueue_main_thread_task(std::packaged_task<void()> task)
void drain_main_thread_tasks() void drain_main_thread_tasks()
{ {
if (auto* app = bound_app()) if (auto* runtime = retained_bound_runtime())
{ {
app->runtime().drain_main_thread_tasks(); runtime->drain_main_thread_tasks();
return; return;
} }
} }

View File

@@ -120,6 +120,7 @@ App* bound_app() noexcept
void release_bound_app() noexcept void release_bound_app() noexcept
{ {
bind_app(nullptr); bind_app(nullptr);
bind_runtime(nullptr);
retained_owned_app().reset(); retained_owned_app().reset();
} }
@@ -136,6 +137,7 @@ int run_main_application(int argc, char** argv)
owned_app = std::make_unique<App>(); owned_app = std::make_unique<App>();
auto* app = owned_app.get(); auto* app = owned_app.get();
bind_app(app); bind_app(app);
bind_runtime(&app->runtime());
app->set_platform_services(&pp::platform::windows::platform_services()); app->set_platform_services(&pp::platform::windows::platform_services());
app->initLog(); app->initLog();

View File

@@ -3,6 +3,7 @@
#include "platform_windows/windows_runtime_state.h" #include "platform_windows/windows_runtime_state.h"
#include "app.h" #include "app.h"
#include "app_runtime.h"
#include "wacom.h" #include "wacom.h"
namespace pp::platform::windows { namespace pp::platform::windows {
@@ -10,6 +11,7 @@ namespace {
struct RetainedWindowsRuntimeState final { struct RetainedWindowsRuntimeState final {
std::unique_ptr<App> owned_app; std::unique_ptr<App> owned_app;
AppRuntime* runtime = nullptr;
WacomTablet tablet; WacomTablet tablet;
}; };
@@ -31,4 +33,14 @@ WacomTablet& retained_wacom_tablet() noexcept
return retained_runtime_state().tablet; return retained_runtime_state().tablet;
} }
AppRuntime* retained_bound_runtime() noexcept
{
return retained_runtime_state().runtime;
}
void bind_runtime(AppRuntime* runtime) noexcept
{
retained_runtime_state().runtime = runtime;
}
} }

View File

@@ -3,11 +3,14 @@
#include <memory> #include <memory>
class App; class App;
class AppRuntime;
class WacomTablet; class WacomTablet;
namespace pp::platform::windows { namespace pp::platform::windows {
[[nodiscard]] std::unique_ptr<App>& retained_owned_app() noexcept; [[nodiscard]] std::unique_ptr<App>& retained_owned_app() noexcept;
[[nodiscard]] WacomTablet& retained_wacom_tablet() noexcept; [[nodiscard]] WacomTablet& retained_wacom_tablet() noexcept;
[[nodiscard]] AppRuntime* retained_bound_runtime() noexcept;
void bind_runtime(AppRuntime* runtime) noexcept;
} }