Zth (libzth)
9_c_api.c

C-API example.

// Default Zth header include.
#include <zth.h>
#include <stdio.h>
// In constrast to C++, fiber entry function must have type void(void*). There
// is no need to do zth_fiber() and friends, just use zth_fiber_create() to run
// the fiber.
void fiber(void* UNUSED_PAR(arg))
{
printf("fiber()\n");
}
int main_fiber(int UNUSED_PAR(argc), char** UNUSED_PAR(argv))
{
printf("main_fiber()\n");
// Start a new fiber, with arg=NULL, default stack, and no name.
zth_fiber_create(fiber, NULL, 0, NULL);
return 0;
}
int main_fiber(int argc, char **argv)
Definition: main.cpp:14
int zth_fiber_create(void(*f)(void *), void *arg=nullptr, size_t stack=0, char const *name=nullptr) noexcept
Run a function as a new fiber.
Definition: async.h:796
fiber_type< F >::factory fiber(F f, char const *name=nullptr)
Create a new fiber.
Definition: async.h:713
#define UNUSED_PAR(name)
Definition: macros.h:79