1 use crate::sync::mpsc::list; 2 3 use loom::thread; 4 use std::sync::Arc; 5 6 #[test] smoke()7fn smoke() { 8 use crate::sync::mpsc::block::Read::*; 9 10 const NUM_TX: usize = 2; 11 const NUM_MSG: usize = 2; 12 13 loom::model(|| { 14 let (tx, mut rx) = list::channel(); 15 let tx = Arc::new(tx); 16 17 for th in 0..NUM_TX { 18 let tx = tx.clone(); 19 20 thread::spawn(move || { 21 for i in 0..NUM_MSG { 22 tx.push((th, i)); 23 } 24 }); 25 } 26 27 let mut next = vec![0; NUM_TX]; 28 29 loop { 30 match rx.pop(&tx) { 31 Some(Value((th, v))) => { 32 assert_eq!(v, next[th]); 33 next[th] += 1; 34 35 if next.iter().all(|&i| i == NUM_MSG) { 36 break; 37 } 38 } 39 Some(Closed) => { 40 panic!(); 41 } 42 None => { 43 thread::yield_now(); 44 } 45 } 46 } 47 }); 48 } 49