klo-routines 0.1.0

Rust cheap coroutines with libc::*context
Documentation

klo-routines

Rust cheap coroutines with libc::*context

Example

use klo_routines::{flush, KloRoutine};

fn main() {
    let mut cnt = 0;
    let mut func = || {
        for _ in 0..16 {
            flush(cnt);
            cnt += 1;
        }
    };

    let mut klo = KloRoutine::new(&mut func);
    while let Some(n) = klo.resume() {
        println!("{}", n);
    }
    
    // or you can use it as iterator
    // for n in &mut klo {
    //     println!("{}", n);
    // }
}

License