diff options
author | bunnei <bunneidev@gmail.com> | 2021-02-27 20:56:04 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2021-02-27 20:56:04 +0100 |
commit | 51fb0a6f9647ba199da10fe4f018ee36e44e65ba (patch) | |
tree | 89cd2ad6dfb310587aa546bb7b9847762795f08f /src/common | |
parent | Merge pull request #5953 from bunnei/memory-refactor-1 (diff) | |
download | yuzu-51fb0a6f9647ba199da10fe4f018ee36e44e65ba.tar yuzu-51fb0a6f9647ba199da10fe4f018ee36e44e65ba.tar.gz yuzu-51fb0a6f9647ba199da10fe4f018ee36e44e65ba.tar.bz2 yuzu-51fb0a6f9647ba199da10fe4f018ee36e44e65ba.tar.lz yuzu-51fb0a6f9647ba199da10fe4f018ee36e44e65ba.tar.xz yuzu-51fb0a6f9647ba199da10fe4f018ee36e44e65ba.tar.zst yuzu-51fb0a6f9647ba199da10fe4f018ee36e44e65ba.zip |
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/fiber.cpp | 14 | ||||
-rw-r--r-- | src/common/fiber.h | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index 3c1eefcb7..b8e98b12a 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp @@ -24,7 +24,7 @@ struct Fiber::FiberImpl { std::function<void(void*)> rewind_point; void* rewind_parameter{}; void* start_parameter{}; - std::shared_ptr<Fiber> previous_fiber; + Fiber* previous_fiber; bool is_thread_fiber{}; bool released{}; @@ -47,7 +47,7 @@ void Fiber::Start(boost::context::detail::transfer_t& transfer) { ASSERT(impl->previous_fiber != nullptr); impl->previous_fiber->impl->context = transfer.fctx; impl->previous_fiber->impl->guard.unlock(); - impl->previous_fiber.reset(); + impl->previous_fiber = nullptr; impl->entry_point(impl->start_parameter); UNREACHABLE(); } @@ -116,20 +116,20 @@ void Fiber::Rewind() { boost::context::detail::jump_fcontext(impl->rewind_context, this); } -void Fiber::YieldTo(std::shared_ptr<Fiber> from, std::shared_ptr<Fiber> to) { +void Fiber::YieldTo(Fiber* from, Fiber* to) { ASSERT_MSG(from != nullptr, "Yielding fiber is null!"); ASSERT_MSG(to != nullptr, "Next fiber is null!"); to->impl->guard.lock(); to->impl->previous_fiber = from; - auto transfer = boost::context::detail::jump_fcontext(to->impl->context, to.get()); + auto transfer = boost::context::detail::jump_fcontext(to->impl->context, to); ASSERT(from->impl->previous_fiber != nullptr); from->impl->previous_fiber->impl->context = transfer.fctx; from->impl->previous_fiber->impl->guard.unlock(); - from->impl->previous_fiber.reset(); + from->impl->previous_fiber = nullptr; } -std::shared_ptr<Fiber> Fiber::ThreadToFiber() { - std::shared_ptr<Fiber> fiber = std::shared_ptr<Fiber>{new Fiber()}; +std::unique_ptr<Fiber> Fiber::ThreadToFiber() { + std::unique_ptr<Fiber> fiber = std::unique_ptr<Fiber>{new Fiber()}; fiber->impl->guard.lock(); fiber->impl->is_thread_fiber = true; return fiber; diff --git a/src/common/fiber.h b/src/common/fiber.h index f7f587f8c..6924f7996 100644 --- a/src/common/fiber.h +++ b/src/common/fiber.h @@ -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); |