summaryrefslogtreecommitdiffstats
path: root/src/common/fiber.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-03-06 02:08:17 +0100
committerGitHub <noreply@github.com>2021-03-06 02:08:17 +0100
commita5ab85ac37bbfed739e75ba9c2226b1e6bf1fd37 (patch)
tree503cbe4fb52939512f8ee0c976e46e9293de3c4c /src/common/fiber.cpp
parentMerge pull request #6034 from Morph1984/mbedtls (diff)
downloadyuzu-a5ab85ac37bbfed739e75ba9c2226b1e6bf1fd37.tar
yuzu-a5ab85ac37bbfed739e75ba9c2226b1e6bf1fd37.tar.gz
yuzu-a5ab85ac37bbfed739e75ba9c2226b1e6bf1fd37.tar.bz2
yuzu-a5ab85ac37bbfed739e75ba9c2226b1e6bf1fd37.tar.lz
yuzu-a5ab85ac37bbfed739e75ba9c2226b1e6bf1fd37.tar.xz
yuzu-a5ab85ac37bbfed739e75ba9c2226b1e6bf1fd37.tar.zst
yuzu-a5ab85ac37bbfed739e75ba9c2226b1e6bf1fd37.zip
Diffstat (limited to '')
-rw-r--r--src/common/fiber.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp
index b8e98b12a..3c1eefcb7 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{};
- Fiber* previous_fiber;
+ std::shared_ptr<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 = nullptr;
+ impl->previous_fiber.reset();
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(Fiber* from, Fiber* to) {
+void Fiber::YieldTo(std::shared_ptr<Fiber> from, std::shared_ptr<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);
+ auto transfer = boost::context::detail::jump_fcontext(to->impl->context, to.get());
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 = nullptr;
+ from->impl->previous_fiber.reset();
}
-std::unique_ptr<Fiber> Fiber::ThreadToFiber() {
- std::unique_ptr<Fiber> fiber = std::unique_ptr<Fiber>{new Fiber()};
+std::shared_ptr<Fiber> Fiber::ThreadToFiber() {
+ std::shared_ptr<Fiber> fiber = std::shared_ptr<Fiber>{new Fiber()};
fiber->impl->guard.lock();
fiber->impl->is_thread_fiber = true;
return fiber;