1 unstable release

0.1.0 Jul 15, 2021

#6 in #flush

MIT/Apache

7KB
159 lines

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

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~44KB