1 #ifndef ZTH_CONTEXT_WINFIBER_H
2 #define ZTH_CONTEXT_WINFIBER_H
12 #ifndef ZTH_CONTEXT_CONTEXT_H
13 # error This file must be included by libzth/context/context.h.
22 class Context :
public impl::ContextArch<Context> {
35 if(ConvertThreadToFiber(
nullptr))
37 else if((res = -(
int)GetLastError()))
75 if((m_fiber = GetCurrentFiber()))
77 }
else if((m_fiber = CreateFiber(
86 if((res = -(
int)GetLastError()))
98 if(
likely(m_fiber != GetCurrentFiber())) {
100 DeleteFiber(m_fiber);
108 zth_assert(to.m_fiber && to.m_fiber != GetCurrentFiber());
109 SwitchToFiber(to.m_fiber);
void valgrindRegister() noexcept
void stackGuardDeinit() noexcept
void deinitStack(Stack &UNUSED_PAR(stack)) noexcept
impl::ContextArch< Context > base
static int init() noexcept
void valgrindDeregister() noexcept
void context_switch(Context &to) noexcept
int stackGuardInit() noexcept
constexpr Context(ContextAttr const &attr) noexcept
int initStack(Stack &UNUSED_PAR(stack), Stack &UNUSED_PAR(usable)) noexcept
Stack const & stack() const noexcept
Return the stack address.
int create() noexcept
Create context.
ContextAttr & attr() noexcept
Return the context attributes, requested by the user.
Worker & currentWorker() noexcept
Return the (thread-local) singleton Worker instance.
#define zth_dbg(group, fmt, a...)
Debug printf()-like function.
#define ZTH_CLASS_NEW_DELETE(T)
Define new/delete operators for a class, which are allocator-aware.
void context_entry(Context *context)
static size_t const DefaultFiberStackSize
Default fiber stack size in bytes.
#define zth_assert(expr)
assert(), but better integrated in Zth.
#define likely(expr)
Marks the given expression to likely be evaluated to true.
#define unlikely(expr)
Marks the given expression to likely be evaluated to true.