Skip to content

Commit 3191f31

Browse files
committed
NO_MERGE: test: add scoped loom test for mpmc::Queue
1 parent 9895080 commit 3191f31

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ stable_deref_trait = { version = "1", default-features = false }
7575
[dev-dependencies]
7676
critical-section = { version = "1.1", features = ["std"] }
7777
static_assertions = "1.1.0"
78-
loom = "0.7"
78+
loom = { version = "0.7", git = "https://github.com/akonradi/loom", branch = "scoped-thread" }
7979

8080
[package.metadata.docs.rs]
8181
features = [

src/mpmc.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,30 @@ mod tests {
505505
});
506506
});
507507
}
508+
509+
#[test]
510+
fn issue_583_enqueue_loom_scope() {
511+
const N: usize = 4;
512+
513+
loom::model(|| {
514+
let q0 = Queue::<u8, N>::new();
515+
for i in 0..N {
516+
q0.enqueue(i as u8).expect("new enqueue");
517+
}
518+
eprintln!("start!");
519+
520+
loom::thread::scope(|sc| {
521+
for _ in 0..2 {
522+
sc.spawn(|| {
523+
for k in 0..1000_000 {
524+
if let Some(v) = q0.dequeue() {
525+
q0.enqueue(v)
526+
.unwrap_or_else(|v| panic!("{k}: q0 -> q0: {v}, {:?}", to_vec(&q0)));
527+
}
528+
}
529+
});
530+
}
531+
});
532+
});
533+
}
508534
}

0 commit comments

Comments
 (0)