Tsucor is a C++ library featuring coroutines from scratch using Assembly for coroutines stack manipulations.
Coroutines implemented:
- Asymmetric stackful
- Symmetric stackful
g++
/clang
CMake
x86-64
Linux
mkdir build
cd build
cmake ..
cmake --build .
A simple generator:
void gen(void* arg) {
for (int i = 0; i < *static_cast<int*>(arg); ++i) {
AsymCoro::yield(&i);
}
AsymCoro::yield(nullptr);
}
int n = 5;
AsymCoro gen_co{gen, &n};
while (true) {
auto i = static_cast<int*>(gen_co());
if (i == nullptr) {
break;
}
std::cout << *i << std::endl;
}