Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3348869

Browse files
committed
move nopreempt sync tests to their own file
1 parent cbb649a commit 3348869

File tree

2 files changed

+41
-32
lines changed

2 files changed

+41
-32
lines changed

tests/pass/concurrency/sync.rs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// ignore-windows: Concurrency on Windows is not supported yet.
2-
// We are making scheduler assumptions here.
3-
// compile-flags: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-preemption-rate=0
2+
// compile-flags: -Zmiri-disable-isolation -Zmiri-strict-provenance
43

54
use std::sync::{Arc, Barrier, Condvar, Mutex, Once, RwLock};
65
use std::thread;
@@ -53,35 +52,6 @@ fn check_conditional_variables_notify_one() {
5352
}
5453
}
5554

56-
fn check_conditional_variables_notify_all() {
57-
let pair = Arc::new(((Mutex::new(())), Condvar::new()));
58-
59-
// Spawn threads and block them on the conditional variable.
60-
let handles: Vec<_> = (0..5)
61-
.map(|_| {
62-
let pair2 = pair.clone();
63-
thread::spawn(move || {
64-
let (lock, cvar) = &*pair2;
65-
let guard = lock.lock().unwrap();
66-
// Block waiting on the conditional variable.
67-
let _ = cvar.wait(guard).unwrap();
68-
})
69-
})
70-
.inspect(|_| {
71-
thread::yield_now();
72-
thread::yield_now();
73-
})
74-
.collect();
75-
76-
let (_, cvar) = &*pair;
77-
// Unblock all threads.
78-
cvar.notify_all();
79-
80-
for handle in handles {
81-
handle.join().unwrap();
82-
}
83-
}
84-
8555
/// Test that waiting on a conditional variable with a timeout does not
8656
/// deadlock.
8757
fn check_conditional_variables_timed_wait_timeout() {
@@ -301,7 +271,6 @@ fn check_condvar() {
301271
fn main() {
302272
check_barriers();
303273
check_conditional_variables_notify_one();
304-
check_conditional_variables_notify_all();
305274
check_conditional_variables_timed_wait_timeout();
306275
check_conditional_variables_timed_wait_notimeout();
307276
check_mutex();
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// ignore-windows: Concurrency on Windows is not supported yet.
2+
// We are making scheduler assumptions here.
3+
// compile-flags: -Zmiri-strict-provenance -Zmiri-preemption-rate=0
4+
5+
use std::sync::{Condvar, Mutex, Arc};
6+
use std::thread;
7+
8+
fn check_conditional_variables_notify_all() {
9+
let pair = Arc::new(((Mutex::new(())), Condvar::new()));
10+
11+
// Spawn threads and block them on the conditional variable.
12+
let handles: Vec<_> = (0..5)
13+
.map(|_| {
14+
let pair2 = pair.clone();
15+
thread::spawn(move || {
16+
let (lock, cvar) = &*pair2;
17+
let guard = lock.lock().unwrap();
18+
// Block waiting on the conditional variable.
19+
let _ = cvar.wait(guard).unwrap();
20+
})
21+
})
22+
.inspect(|_| {
23+
// Ensure the other threads all run and block on the `wait`.
24+
thread::yield_now();
25+
thread::yield_now();
26+
})
27+
.collect();
28+
29+
let (_, cvar) = &*pair;
30+
// Unblock all threads.
31+
cvar.notify_all();
32+
33+
for handle in handles {
34+
handle.join().unwrap();
35+
}
36+
}
37+
38+
fn main() {
39+
check_conditional_variables_notify_all();
40+
}

0 commit comments

Comments
 (0)