]> git.proxmox.com Git - rustc.git/blob - tests/ui/threads-sendsync/task-comm-10.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / threads-sendsync / task-comm-10.rs
1 // run-pass
2 #![allow(unused_must_use)]
3 #![allow(unused_mut)]
4 // ignore-emscripten no threads support
5
6 use std::thread;
7 use std::sync::mpsc::{channel, Sender};
8
9 fn start(tx: &Sender<Sender<String>>) {
10 let (tx2, rx) = channel();
11 tx.send(tx2).unwrap();
12
13 let mut a;
14 let mut b;
15 a = rx.recv().unwrap();
16 assert_eq!(a, "A".to_string());
17 println!("{}", a);
18 b = rx.recv().unwrap();
19 assert_eq!(b, "B".to_string());
20 println!("{}", b);
21 }
22
23 pub fn main() {
24 let (tx, rx) = channel();
25 let child = thread::spawn(move|| { start(&tx) });
26
27 let mut c = rx.recv().unwrap();
28 c.send("A".to_string()).unwrap();
29 c.send("B".to_string()).unwrap();
30 thread::yield_now();
31
32 child.join();
33 }