diff options
| author | bunnei <bunneidev@gmail.com> | 2021-02-27 11:56:04 -0800 |
|---|---|---|
| committer | bunnei <bunneidev@gmail.com> | 2021-02-27 11:56:04 -0800 |
| commit | 51fb0a6f9647ba199da10fe4f018ee36e44e65ba (patch) | |
| tree | 89cd2ad6dfb310587aa546bb7b9847762795f08f /src/core/hle/kernel/k_scheduler.h | |
| parent | 09f7c355c6d7e3c7845ba96d9704489d2d5853f4 (diff) | |
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.
Diffstat (limited to 'src/core/hle/kernel/k_scheduler.h')
| -rw-r--r-- | src/core/hle/kernel/k_scheduler.h | 10 |
1 files changed, 5 insertions, 5 deletions
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<Common::Fiber>& ControlContext() { - return switch_fiber; + [[nodiscard]] Common::Fiber* ControlContext() { + return switch_fiber.get(); } - [[nodiscard]] const std::shared_ptr<Common::Fiber>& 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<Common::Fiber> switch_fiber{}; + std::unique_ptr<Common::Fiber> switch_fiber{}; struct SchedulingState { std::atomic<bool> needs_scheduling; |
