fix test_weak_count_locked for Miri
This commit is contained in:
parent
c66d02e3ba
commit
7bea58eeac
|
@ -340,7 +340,9 @@ fn test_weak_count_locked() {
|
|||
let mut a = Arc::new(atomic::AtomicBool::new(false));
|
||||
let a2 = a.clone();
|
||||
let t = thread::spawn(move || {
|
||||
for _i in 0..1000000 {
|
||||
// Miri is too slow
|
||||
let count = if cfg!(miri) { 1000 } else { 1000000 };
|
||||
for _i in 0..count {
|
||||
Arc::get_mut(&mut a);
|
||||
}
|
||||
a.store(true, SeqCst);
|
||||
|
@ -349,6 +351,8 @@ fn test_weak_count_locked() {
|
|||
while !a2.load(SeqCst) {
|
||||
let n = Arc::weak_count(&a2);
|
||||
assert!(n < 2, "bad weak count: {}", n);
|
||||
#[cfg(miri)] // Miri's scheduler does not guarantee liveness, and thus needs this hint.
|
||||
atomic::spin_loop_hint();
|
||||
}
|
||||
t.join().unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue