Browse Source

[common/fiber] use std::vector<> for allocating stack instead of virtualBuffer<>

Signed-off-by: lizzie <lizzie@eden-emu.dev>
pull/3264/head
lizzie 1 month ago
committed by crueter
parent
commit
2247f084ef
  1. 11
      src/common/fiber.cpp

11
src/common/fiber.cpp

@ -17,10 +17,10 @@ namespace Common {
constexpr std::size_t default_stack_size = 512 * 1024;
struct Fiber::FiberImpl {
FiberImpl() : stack{default_stack_size}, rewind_stack{default_stack_size} {}
FiberImpl() : stack(default_stack_size), rewind_stack(default_stack_size) {}
VirtualBuffer<u8> stack;
VirtualBuffer<u8> rewind_stack;
std::vector<u8> stack;
std::vector<u8> rewind_stack;
std::mutex guard;
std::function<void()> entry_point;
@ -105,8 +105,7 @@ void Fiber::Rewind() {
ASSERT(impl->rewind_point);
ASSERT(impl->rewind_context == nullptr);
u8* stack_base = impl->rewind_stack_limit + default_stack_size;
impl->rewind_context =
boost::context::detail::make_fcontext(stack_base, impl->stack.size(), RewindStartFunc);
impl->rewind_context = boost::context::detail::make_fcontext(stack_base, impl->stack.size(), RewindStartFunc);
boost::context::detail::jump_fcontext(impl->rewind_context, this);
}
@ -119,7 +118,7 @@ void Fiber::YieldTo(std::weak_ptr<Fiber> weak_from, Fiber& to) {
// "from" might no longer be valid if the thread was killed
if (auto from = weak_from.lock()) {
if (from->impl->previous_fiber == nullptr) {
ASSERT_MSG(false, "previous_fiber is nullptr!");
ASSERT(false && "previous_fiber is nullptr!");
return;
}
from->impl->previous_fiber->impl->context = transfer.fctx;

Loading…
Cancel
Save