1 use crate::sync::mpsc::{channel, TryRecvError};
2 use crate::sync::{Arc, Barrier};
6 #[cfg_attr(target_os = "emscripten", ignore)]
10 let barrier = Arc::new(Barrier::new(N));
11 let (tx, rx) = channel();
14 let c = barrier.clone();
16 thread::spawn(move || {
17 tx.send(c.wait().is_leader()).unwrap();
21 // At this point, all spawned threads should be blocked,
22 // so we shouldn't get anything from the port
23 assert!(matches!(rx.try_recv(), Err(TryRecvError::Empty)));
25 let mut leader_found = barrier.wait().is_leader();
27 // Now, the barrier is cleared and we should get data.
29 if rx.recv().unwrap() {
30 assert!(!leader_found);
34 assert!(leader_found);