use orx_concurrent_vec::*; #[test] fn exact_len_with_slow_writer() { let vec = ConcurrentVec::::new(); let slow_iterator = (0..10).map(|i| match i { 5 => { std::thread::sleep(std::time::Duration::from_millis(100)); 42 } _ => { std::thread::sleep(std::time::Duration::from_millis(1)); i } }); std::thread::scope(|s| { let vec = &vec; // reader s.spawn(move || { let mut i = 0; loop { let exact_len = vec.len(); let str = format!("len at {} = {}", i, exact_len); dbg!(str); std::thread::sleep(std::time::Duration::from_millis(1)); match i { i if (20..80).contains(&i) => assert_eq!(exact_len, 5), _ => {} } i += 1; if exact_len == 10 { break; } } }); vec.extend(slow_iterator); }); }