Skip to content

Cortex v0.2.0

Latest

Choose a tag to compare

@GhevondW GhevondW released this 01 Feb 07:19
· 30 commits to main since this release

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 and Create()/Step() for event-loop integration (perfect for WASM)
  • Future: Async result handling with Get() and Wait() 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 with SchedulerStoppingError
  • 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
    });
}