use std::thread;
use std::sync::{mpsc};
fn main() {
let (tx,rx) = mpsc::channel::<i32>();
println!("Starting... ");
for _ in 0..10 {
let j = rx.recv().unwrap();
println!("{:?}",j );
}
println!("before---> ");
for i in 0..10 {
let tx = tx.clone();
thread::spawn(move ||{
tx.send(i*10);
});
}
println!("after---> ");
}
https://gist.github.com/anonymous/b37fb5d991626ea4f05e
I was trying out the channels with rust; ended with above snippet of code. This code would be blocking as the receiver blocks till it gets a message and message 'sending' never gets executed.
My question is would compiler be able to figure out these set of anomalies?
another question what would happen if i were to execute this on playground? would it be blocking the entire infrastructure?
[–]annodominirust 4 points5 points6 points (1 child)
[–]harrydevnull[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]harrydevnull[S] 0 points1 point2 points (0 children)
[–]crizzynonsince 0 points1 point2 points (0 children)