-
-
Save ayosec/b1386b3afcdc38eaefef to your computer and use it in GitHub Desktop.
Rust mpmc_bounded_queue::Queue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::sync::mpmc_bounded_queue::Queue; | |
use std::io::Timer; | |
use std::time::Duration; | |
fn main() { | |
let queue: Queue<i8> = Queue::with_capacity(10); | |
queue.push(0); | |
let q1 = queue.clone(); | |
spawn(proc() { | |
q1.push(10); | |
q1.push(11); | |
q1.push(12); | |
}); | |
let q2 = queue.clone(); | |
spawn(proc() { | |
println!("proc {}", q2.pop()); | |
}); | |
let mut timer = Timer::new().unwrap(); | |
timer.sleep(Duration::milliseconds(10)); | |
loop { | |
match queue.pop() { | |
Some(x) => println!("main {}", x), | |
None => break | |
} | |
} | |
println!("END"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment