mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-20 12:55:45 +00:00
Implemented rewindless Fiber without Boost (using minicoro)
This commit is contained in:
parent
60643dd1b2
commit
16f92e5b32
9 changed files with 2119 additions and 157 deletions
|
@ -6,9 +6,7 @@
|
|||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace boost::context::detail {
|
||||
struct transfer_t;
|
||||
}
|
||||
#include "common/minicoro.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
|
@ -38,25 +36,18 @@ public:
|
|||
Fiber(Fiber&&) = default;
|
||||
Fiber& operator=(Fiber&&) = default;
|
||||
|
||||
/// Yields control from Fiber 'from' to Fiber 'to'
|
||||
/// Fiber 'from' must be the currently running fiber.
|
||||
static void YieldTo(std::weak_ptr<Fiber> weak_from, Fiber& to);
|
||||
[[nodiscard]] static std::shared_ptr<Fiber> ThreadToFiber();
|
||||
|
||||
void SetRewindPoint(std::function<void()>&& rewind_func);
|
||||
|
||||
void Rewind();
|
||||
|
||||
/// Only call from main thread's fiber
|
||||
void Exit();
|
||||
|
||||
private:
|
||||
Fiber();
|
||||
|
||||
void OnRewind(boost::context::detail::transfer_t& transfer);
|
||||
void Start(boost::context::detail::transfer_t& transfer);
|
||||
static void FiberStartFunc(boost::context::detail::transfer_t transfer);
|
||||
static void RewindStartFunc(boost::context::detail::transfer_t transfer);
|
||||
void DestroyPre();
|
||||
void DestroyWorkFiber();
|
||||
void DestroyThreadFiber();
|
||||
|
||||
struct FiberImpl;
|
||||
std::unique_ptr<FiberImpl> impl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue