From 51fb0a6f9647ba199da10fe4f018ee36e44e65ba Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 27 Feb 2021 11:56:04 -0800 Subject: core: Switch to unique_ptr for usage of Common::Fiber. - With using unique_ptr instead of shared_ptr, we have more explicit ownership of the context. - Fixes a memory leak due to circular reference of the shared pointer. --- src/core/hle/kernel/k_scheduler.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/core/hle/kernel/k_scheduler.h') diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index f595b9a5c..a4285c595 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h @@ -68,12 +68,12 @@ public: void OnThreadStart(); - [[nodiscard]] std::shared_ptr& ControlContext() { - return switch_fiber; + [[nodiscard]] Common::Fiber* ControlContext() { + return switch_fiber.get(); } - [[nodiscard]] const std::shared_ptr& ControlContext() const { - return switch_fiber; + [[nodiscard]] const Common::Fiber* ControlContext() const { + return switch_fiber.get(); } [[nodiscard]] u64 UpdateHighestPriorityThread(KThread* highest_thread); @@ -178,7 +178,7 @@ private: KThread* idle_thread; - std::shared_ptr switch_fiber{}; + std::unique_ptr switch_fiber{}; struct SchedulingState { std::atomic needs_scheduling; -- cgit v1.2.3