mco 0.1.48

Rust Coroutine Library like go
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use mco::co;
use mco::coroutine::sleep;
use mco::std::time::tick::Ticker;
use std::sync::Arc;
use std::time::Duration;

fn main() {
    let mut t = Ticker::new_arc(Duration::from_secs(1));
    let tclone = t.clone();
    co!(move || {
        for x in tclone.as_ref() {
            println!("tick {}", x);
        }
    });
    sleep(Duration::from_secs(3));
    t.stop();
}