summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-02-10 13:18:23 -0400
committerGravatar Fernando Sahmkow2020-06-18 16:29:19 -0400
commit03e4f5dac436fe361834e6b9918983e9c4787acb (patch)
treee7f25edf95ce85d07e203afb2df13830bf87907e /src
parentCommon: Refactor & Document Wall clock. (diff)
downloadyuzu-03e4f5dac436fe361834e6b9918983e9c4787acb.tar.gz
yuzu-03e4f5dac436fe361834e6b9918983e9c4787acb.tar.xz
yuzu-03e4f5dac436fe361834e6b9918983e9c4787acb.zip
Common: Correct fcontext fibers.
Diffstat (limited to 'src')
-rw-r--r--src/common/fiber.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp
index a88a30ced..e91d86dbe 100644
--- a/src/common/fiber.cpp
+++ b/src/common/fiber.cpp
@@ -12,6 +12,7 @@
12 12
13namespace Common { 13namespace Common {
14 14
15
15#ifdef _MSC_VER 16#ifdef _MSC_VER
16 17
17struct Fiber::FiberImpl { 18struct Fiber::FiberImpl {
@@ -82,7 +83,6 @@ std::shared_ptr<Fiber> Fiber::ThreadToFiber() {
82} 83}
83 84
84#else 85#else
85
86constexpr std::size_t default_stack_size = 1024 * 1024 * 4; // 4MB 86constexpr std::size_t default_stack_size = 1024 * 1024 * 4; // 4MB
87 87
88struct alignas(64) Fiber::FiberImpl { 88struct alignas(64) Fiber::FiberImpl {
@@ -108,9 +108,8 @@ void Fiber::FiberStartFunc(boost::context::detail::transfer_t transfer)
108Fiber::Fiber(std::function<void(void*)>&& entry_point_func, void* start_parameter) 108Fiber::Fiber(std::function<void(void*)>&& entry_point_func, void* start_parameter)
109 : guard{}, entry_point{std::move(entry_point_func)}, start_parameter{start_parameter}, previous_fiber{} { 109 : guard{}, entry_point{std::move(entry_point_func)}, start_parameter{start_parameter}, previous_fiber{} {
110 impl = std::make_unique<FiberImpl>(); 110 impl = std::make_unique<FiberImpl>();
111 auto start_func = std::bind(&Fiber::start, this); 111 impl->context = boost::context::detail::make_fcontext(impl->stack.data(), impl->stack.size(),
112 impl->context = 112 FiberStartFunc);
113 boost::context::detail::make_fcontext(impl->stack.data(), impl->stack.size(), &start_func);
114} 113}
115 114
116Fiber::Fiber() : guard{}, entry_point{}, start_parameter{}, previous_fiber{} { 115Fiber::Fiber() : guard{}, entry_point{}, start_parameter{}, previous_fiber{} {
@@ -139,7 +138,7 @@ void Fiber::YieldTo(std::shared_ptr<Fiber> from, std::shared_ptr<Fiber> to) {
139 ASSERT_MSG(to != nullptr, "Next fiber is null!"); 138 ASSERT_MSG(to != nullptr, "Next fiber is null!");
140 to->guard.lock(); 139 to->guard.lock();
141 to->previous_fiber = from; 140 to->previous_fiber = from;
142 auto transfer = boost::context::detail::jump_fcontext(to->impl.context, nullptr); 141 auto transfer = boost::context::detail::jump_fcontext(to->impl->context, nullptr);
143 auto previous_fiber = from->previous_fiber; 142 auto previous_fiber = from->previous_fiber;
144 ASSERT(previous_fiber != nullptr); 143 ASSERT(previous_fiber != nullptr);
145 previous_fiber->impl->context = transfer.fctx; 144 previous_fiber->impl->context = transfer.fctx;