once_lock: make test not take as long in Miri · model-checking/verify-rust-std@7177ac8 (original) (raw)

Original file line number Diff line number Diff line change
@@ -80,14 +80,21 @@ use crate::sync::Once;
80 80 /// static LIST: OnceList = OnceList::new();
81 81 /// static COUNTER: AtomicU32 = AtomicU32::new(0);
82 82 ///
83 -/// let vec = (0..thread::available_parallelism().unwrap().get()).map(|_
84 -/// while let i @ 0..=1000 = COUNTER.fetch_add(1, Ordering::Relaxed) {
85 -/// LIST.push(i);
83 +/// # const LEN: u32 = if cfg!(miri) { 50 } else { 1000 };
84 +/// # /*
85 +/// const LEN: u32 = 1000;
86 +/// # */
87 +/// thread::scope(|s
88 +/// for _ in 0..thread::available_parallelism().unwrap().get() {
89 +/// s.spawn(|
90 +/// while let i @ 0..LEN = COUNTER.fetch_add(1, Ordering::Relaxed) {
91 +/// LIST.push(i);
92 +/// }
93 +/// });
86 94 /// }
87 -/// })).collect::<Vec<thread::JoinHandle<_>>>();
88 -/// vec.into_iter().for_each(|handle
95 +/// });
89 96 ///
90 -/// for i in 0..=1000 {
97 +/// for i in 0..LEN {
91 98 /// assert!(LIST.contains(&i));
92 99 /// }
93 100 ///