Minicoro: Single header stackful cross-platform coroutine library in pure C
8 days ago
- #asynchronous
- #coroutines
- #C programming
- Minicoro is a single-file library for asymmetric coroutines in C, inspired by Lua coroutines.
- Supports stackful asymmetric coroutines, nesting coroutines, custom allocators, and customizable stack sizes.
- Features include yield across any C function, multithread support, cross-platform compatibility, and minimal dependencies.
- Implementation methods vary by platform, including assembly, ucontext, or fibers, with assembly being the most efficient.
- Provides a storage system for passing values between yield and resume, and supports custom allocators.
- Includes warnings about C++ exceptions, RAII, thread safety, and stack space limitations.
- Benchmarks show assembly method is fastest for context switching.
- Detailed API reference provided for coroutine creation, management, and storage operations.
- Example code demonstrates basic usage and a Fibonacci sequence generator using coroutines.
- Recent updates include virtual memory allocator support, WebAssembly compatibility, and various fixes.