Rust cheap coroutines with libc::*context
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);
// }
}
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.