YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
execution_context.cpp
Go to the documentation of this file.
2
3#include <cstdlib>
4
5namespace yaclib::detail::fiber {
6
8 if (getcontext(&_context) == -1) {
9 abort();
10 }
11 _context.uc_stack.ss_sp = stack.start;
12 _context.uc_stack.ss_size = stack.size;
13 makecontext(&_context, reinterpret_cast<void (*)()>(trampoline), 1, arg);
14}
15
17#ifdef YACLIB_ASAN
18 __sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr);
19#endif
20}
21
23#ifdef YACLIB_ASAN
24 void* fake_stack{nullptr};
25 __sanitizer_start_switch_fiber(&fake_stack, other._context.uc_stack.ss_sp, other._context.uc_stack.ss_size);
26#endif
27 swapcontext(&_context, &other._context);
28#ifdef YACLIB_ASAN
30#endif
31}
32
34#ifdef YACLIB_ASAN
35 __sanitizer_start_switch_fiber(nullptr, other._context.uc_stack.ss_sp, other._context.uc_stack.ss_size);
36#endif
37 setcontext(&other._context);
38}
39
40} // namespace yaclib::detail::fiber
void SwitchTo(ExecutionContext &other)
void Setup(Allocation stack, Trampoline trampoline, void *arg)
void(*)(void *arg) Trampoline
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25