]> git.lizzy.rs Git - rust.git/blob - src/test/ui/threads-sendsync/task-comm-15.rs
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
[rust.git] / src / test / ui / threads-sendsync / task-comm-15.rs
1 // run-pass
2 #![allow(unused_must_use)]
3 // ignore-emscripten no threads support
4 // pretty-expanded FIXME #23616
5
6 use std::sync::mpsc::{channel, Sender};
7 use std::thread;
8
9 fn start(tx: &Sender<isize>, i0: isize) {
10     let mut i = i0;
11     while i > 0 {
12         tx.send(0).unwrap();
13         i = i - 1;
14     }
15 }
16
17 pub fn main() {
18     // Spawn a thread that sends us back messages. The parent thread
19     // is likely to terminate before the child completes, so from
20     // the child's point of view the receiver may die. We should
21     // drop messages on the floor in this case, and not crash!
22     let (tx, rx) = channel();
23     let t = thread::spawn(move|| {
24         start(&tx, 10)
25     });
26     rx.recv();
27     t.join();
28 }