1 #ifndef ARCH_SETJMP_SETJMP_H
2 #define ARCH_SETJMP_SETJMP_H
29 SetJmp(
const Entry &entry,
const size_t stackSize = 0);
63 return reinterpret_cast<sigjmp_buf *
>(
static_cast<SetJmp *
>(thread)->
stack.data());
66 static void AllocMainCothread();
67 static void InvokeCothreadDidReturnHandler(Cothread *from);
68 static void SignalHandlerSetupThunk(
int);
110 static thread_local std::array<uintptr_t, kMainStackSize> gMainStack;
117 static EntryContext *gCurrentlyPreparing;
128 static std::mutex gSignalLock;
132 bool ownsStack{
false};
std::function< void()> Entry
Type alias for an entry point of a cothread.
Context switching utilizing the C library setjmp() and longjmp() methods.
static constexpr const size_t kStackAlignment
SetJmp(const Entry &entry, const size_t stackSize=0)
void switchTo(CothreadImpl *from) override
static constexpr const size_t kDefaultStackSize
SetJmp(std::span< uintptr_t > stack)
static constexpr const size_t kMainStackSize
Implementation details (including architecture/platform specific code) for the library.
CothreadImpl * AllocKernelThreadWrapper()
Abstract interface for a platform implementation of cothreads.
CothreadImpl(const Cothread::Entry &entry, const size_t stackSize=0)
std::span< uintptr_t > stack
Stack used by this cothread, if any.