/fiber

A header only cross platform wrapper of fiber API.

Primary LanguageCMIT LicenseMIT

Fiber

Header only cross platform wrapper of fiber API

A fiber is a particularly lightweight thread of execution. Which is useful for implementing coroutine, iterator, lightweight thread, etc.

How to use

Just #include "fiber.h" before using this library.

There are quite few interfaces:

FBAPI static bool_t fiber_is_current(const fiber_t* const fb);
FBAPI static fiber_t* fiber_create(fiber_t* primary, size_t stack, fiber_proc run, void* userdata);
FBAPI static bool_t fiber_delete(fiber_t* fb);
FBAPI static bool_t fiber_switch(fiber_t* fb);

Read comments in code to get the usage, or start with a simple example.

Dependency/Backend

Drafting

This library is supposed to be cross platform as possible. However it's drafting because I've only implemented and tested it on Windows, POSIX and JavaScript platforms. Supporting for more platforms will be added in the future; any pull requests are welcome.