Skip to content

Commit 63448e5

Browse files
committed
add loom test for iterator linearizability
1 parent c1013ff commit 63448e5

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/loom.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ fn read_write() {
4747
});
4848
}
4949

50+
#[test]
51+
fn iter_linearizability() {
52+
loom::model(|| {
53+
let vec = Arc::new(boxcar::Vec::new());
54+
let v1 = vec.clone();
55+
let v2 = vec.clone();
56+
57+
let t1 = thread::spawn(move || v1.push(1));
58+
let t2 = thread::spawn(move || {
59+
v2.push(2);
60+
assert!(v2.iter().find(|&(_, x)| *x == 2).is_some());
61+
});
62+
63+
t1.join().unwrap();
64+
t2.join().unwrap();
65+
});
66+
}
67+
5068
#[test]
5169
fn mixed() {
5270
loom::model(|| {

0 commit comments

Comments
 (0)