may 0.3.51

Rust Stackful Coroutine Library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::time::Duration;

fn main() {
    may::go!(|| {
        let (sx1, rx1) = may::sync::mpsc::channel();
        let (sx2, rx2) = may::sync::mpsc::channel();
        sx1.send(100i32).unwrap();
        sx2.send(200i32).unwrap();

        may::loop_select!(
            v1 = rx1.recv() => println!("v1={:?}", v1),
            v2 = rx2.recv() => println!("v2={:?}", v2)
        );
    });
    std::thread::sleep(Duration::from_secs(1));
}