From 0dc65bf435dfd7d791b271df0c84378b38b2c555 Mon Sep 17 00:00:00 2001 From: Jesse Talavera-Greenberg Date: Thu, 24 Aug 2023 22:18:30 -0400 Subject: [PATCH] Split up retro::task::deinit into wait and reset --- src/libretro/libretro.cpp | 2 ++ src/libretro/retro/task_queue.cpp | 12 ++++++++++-- src/libretro/retro/task_queue.hpp | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index e79be92..67e6d66 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -440,6 +440,8 @@ PUBLIC_SYMBOL void retro_unload_game(void) { // No need to flush the homebrew save data either, the CartHomebrew destructor does that // The cleanup handlers for each task will flush data to disk if needed + retro::task::reset(); + retro::task::wait(); retro::task::deinit(); if (NDS::Running) diff --git a/src/libretro/retro/task_queue.cpp b/src/libretro/retro/task_queue.cpp index ab4df1a..a82ab34 100644 --- a/src/libretro/retro/task_queue.cpp +++ b/src/libretro/retro/task_queue.cpp @@ -44,13 +44,21 @@ void retro::task::push(TaskSpec&& task) noexcept { task._task = nullptr; } +void retro::task::wait() noexcept { + ZoneScopedN("retro::task::wait"); + task_queue_wait(nullptr, nullptr); // wait for all tasks to finish +} + void retro::task::deinit() noexcept { ZoneScopedN("retro::task::deinit"); - task_queue_reset(); // cancel all outstanding tasks - task_queue_wait(nullptr, nullptr); // wait for all tasks to finish task_queue_deinit(); } +void retro::task::reset() noexcept { + ZoneScopedN("retro::task::reset"); + task_queue_reset(); // cancel all outstanding tasks +} + void retro::task::check() noexcept { ZoneScopedN("retro::task::check"); task_queue_check(); diff --git a/src/libretro/retro/task_queue.hpp b/src/libretro/retro/task_queue.hpp index ea9f0c3..f7a9a41 100644 --- a/src/libretro/retro/task_queue.hpp +++ b/src/libretro/retro/task_queue.hpp @@ -35,7 +35,9 @@ namespace retro::task { void push(TaskSpec&& task) noexcept; void check() noexcept; + void reset() noexcept; void deinit() noexcept; + void wait() noexcept; class TaskSpec { public: