Split Linux platform target and move runtime/platform state

This commit is contained in:
2026-06-17 01:20:11 +02:00
parent 90a55b86fe
commit 3ce365fc15
16 changed files with 169 additions and 94 deletions

View File

@@ -99,24 +99,6 @@ void win32_save_window_state()
namespace pp::platform::windows {
namespace {
struct RetainedMainTaskQueue final {
std::deque<std::packaged_task<void()>> tasklist;
std::mutex task_mutex;
};
[[nodiscard]] RetainedMainTaskQueue& retained_main_task_queue()
{
static RetainedMainTaskQueue queue;
return queue;
}
void enqueue_main_task(std::packaged_task<void()> task)
{
auto& queue = retained_main_task_queue();
std::lock_guard<std::mutex> lock(queue.task_mutex);
queue.tasklist.emplace_back(std::move(task));
}
struct RetainedWin32AsyncRenderContextState final {
HDC hdc{};
HGLRC hrc{};
@@ -189,23 +171,18 @@ void swap_async_render_context()
void enqueue_main_thread_task(std::packaged_task<void()> task)
{
enqueue_main_task(std::move(task));
if (!App::I)
{
task();
return;
}
App::I->runtime().main_thread_task(std::move(task));
}
void drain_main_thread_tasks()
{
std::deque<std::packaged_task<void()>> working_list;
{
auto& queue = retained_main_task_queue();
std::lock_guard<std::mutex> lock(queue.task_mutex);
working_list = std::move(queue.tasklist);
}
while (!working_list.empty())
{
working_list.front()();
working_list.pop_front();
}
if (App::I)
App::I->runtime().drain_main_thread_tasks();
}
} // namespace pp::platform::windows