From 68ffac250ae2d1c2d5d961304d2c61f6755ab033 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 5 Mar 2021 22:10:03 -0800 Subject: common: fiber: Use weak_ptr when yielding. - Avoids a memory leak, as taking a strong reference of the fiber here causes a circular reference. - Supersedes #6006 with a more narrow fix. --- src/common/fiber.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common/fiber.h') diff --git a/src/common/fiber.h b/src/common/fiber.h index f7f587f8c..d96be6019 100644 --- a/src/common/fiber.h +++ b/src/common/fiber.h @@ -41,7 +41,7 @@ public: /// Yields control from Fiber 'from' to Fiber 'to' /// Fiber 'from' must be the currently running fiber. - static void YieldTo(std::shared_ptr from, std::shared_ptr to); + static void YieldTo(std::weak_ptr weak_from, std::shared_ptr to); [[nodiscard]] static std::shared_ptr ThreadToFiber(); void SetRewindPoint(std::function&& rewind_func, void* rewind_param); -- cgit v1.2.3 From 8f7eb194af199ef7a3b225399e8d6fede27234f2 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 7 Mar 2021 13:46:53 -0800 Subject: common: Fiber: use a reference for YieldTo. - Fixes another small leak. --- src/common/fiber.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common/fiber.h') diff --git a/src/common/fiber.h b/src/common/fiber.h index d96be6019..f2a8ff29a 100644 --- a/src/common/fiber.h +++ b/src/common/fiber.h @@ -41,7 +41,7 @@ public: /// Yields control from Fiber 'from' to Fiber 'to' /// Fiber 'from' must be the currently running fiber. - static void YieldTo(std::weak_ptr weak_from, std::shared_ptr to); + static void YieldTo(std::weak_ptr weak_from, Fiber& to); [[nodiscard]] static std::shared_ptr ThreadToFiber(); void SetRewindPoint(std::function&& rewind_func, void* rewind_param); -- cgit v1.2.3