]> git.lizzy.rs Git - rust.git/blob - tests/ui/threads-sendsync/task-comm-0.rs
Auto merge of #106853 - TimNN:undo-remap, r=oli-obk
[rust.git] / tests / ui / threads-sendsync / task-comm-0.rs
1 // run-pass
2 #![allow(unused_must_use)]
3 // ignore-emscripten no threads support
4
5 use std::thread;
6 use std::sync::mpsc::{channel, Sender};
7
8 pub fn main() { test05(); }
9
10 fn test05_start(tx : &Sender<isize>) {
11     tx.send(10).unwrap();
12     println!("sent 10");
13     tx.send(20).unwrap();
14     println!("sent 20");
15     tx.send(30).unwrap();
16     println!("sent 30");
17 }
18
19 fn test05() {
20     let (tx, rx) = channel();
21     let t = thread::spawn(move|| { test05_start(&tx) });
22     let mut value: isize = rx.recv().unwrap();
23     println!("{}", value);
24     value = rx.recv().unwrap();
25     println!("{}", value);
26     value = rx.recv().unwrap();
27     println!("{}", value);
28     assert_eq!(value, 30);
29     t.join();
30 }