Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paladin-t/fiber
A header only cross platform wrapper of fiber API.
https://github.com/paladin-t/fiber
coroutine fiber
Last synced: 3 months ago
JSON representation
A header only cross platform wrapper of fiber API.
- Host: GitHub
- URL: https://github.com/paladin-t/fiber
- Owner: paladin-t
- License: mit
- Created: 2017-11-17T06:13:44.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-22T11:18:38.000Z (over 6 years ago)
- Last Synced: 2024-05-02T13:21:11.513Z (6 months ago)
- Topics: coroutine, fiber
- Language: C
- Homepage:
- Size: 406 KB
- Stars: 43
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - fiber
README
## Fiber
**Header only cross platform wrapper of fiber API**
A [fiber](https://en.wikipedia.org/wiki/Fiber_(computer_science)) 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:
~~~~~~~~~~c
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](fiber.h) to get the usage, or start with a simple [example](test.c).
### Dependency/Backend
* Windows backend with [`fiber` functions](https://msdn.microsoft.com/en-us/library/windows/desktop/ms684847(v=vs.85).aspx#fiber_functions)
* POSIX backend with [`setcontext` functions](https://en.wikipedia.org/wiki/Setcontext)
* JavaScript backend with [`asyncify` functions](http://kripken.github.io/emscripten-site/docs/api_reference/emscripten.h.html#asyncify-functions)### 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.