Repository navigation
Cortex v0.2.0 - tiny_fiber Cooperative Multitasking
This release introduces tiny_fiber, a cooperative multitasking module built on top of the Cortex coroutine library.
Key Features
tiny_fiber Module
- Scheduler: Cooperative fiber scheduler with
Run()for blocking execution andCreate()/Step()for event-loop integration (perfect for WASM) - Future: Async result handling with
Get()andWait()methods - Cooperative Mutex: Non-blocking mutex that yields to other fibers when contended
- Cooperative ConditionVariable: Signal/wait coordination between fibers
- Graceful Shutdown:
Scheduler::Stop()for clean resource cleanup withSchedulerStoppingError - Yield(): Explicit control transfer between fibers
Generator Support
- New
Generator<T>class for lazy sequence generation using coroutines
New WASM Demos
- Fiber Workflow Demo: Interactive visualization of cooperative multitasking
- Particle Simulation: Physics demo using coroutines
- Sudoku Solver: Backtracking solver with step-by-step visualization
Example Usage
#include <cortex/tiny_fiber/tiny_fiber.hpp>
namespace tf = cortex::tiny_fiber;
int main() {
tf::Scheduler::Run([] {
auto future = tf::Spawn<int>([] {
tf::Yield();
return 42;
});
int result = future.Get(); // Waits cooperatively
});
}