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.
This commit is contained in:
bunnei 2021-02-27 11:56:04 -08:00
parent 09f7c355c6
commit 51fb0a6f96
10 changed files with 58 additions and 59 deletions

View file

@ -41,8 +41,8 @@ public:
/// Yields control from Fiber 'from' to Fiber 'to'
/// Fiber 'from' must be the currently running fiber.
static void YieldTo(std::shared_ptr<Fiber> from, std::shared_ptr<Fiber> to);
[[nodiscard]] static std::shared_ptr<Fiber> ThreadToFiber();
static void YieldTo(Fiber* from, Fiber* to);
[[nodiscard]] static std::unique_ptr<Fiber> ThreadToFiber();
void SetRewindPoint(std::function<void(void*)>&& rewind_func, void* rewind_param);