my3157 / toy-runtime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

toy-rumtime

Demonstrates rust async runtime, just show how Future Waker vtable work.

fn main() {
    let toy = Toy::new();

    for i in 1..=20 {
        toy.spawn(async move {
            let ret = FakeIO::new(Duration::from_secs(i)).await;
            println!("{:?}: {:?}", thread::current().id(), ret);
        })
    }

    toy.run(4); // 4 threads
}

About


Languages

Language:Rust 100.0%