-
Notifications
You must be signed in to change notification settings - Fork 213
Open
Description
#[test]
fn test_() {
const N: usize = 4;
let q0 = Q::<u8, N>::new();
for i in 0..N {
q0.enqueue(i as u8).expect("new enqueue");
}
eprintln!("start!");
std::thread::scope(|sc| {
for i in 0..2 {
sc.spawn(|| {
for k in 0..1000_000 {
if let Some(v) = q0.dequeue() {
q0.enqueue(v).unwrap_or_else(|v| panic!("{}: q0 -> q0: {}, {:?}", k, v, to_vec(&q0)));
}
}
});
}
});
}
fn to_vec<T, const N: usize>(q: &Q<T, N>) -> Vec<T> { // inaccurate
let mut ret = vec![];
while let Some(v) = q.dequeue() {
ret.push(v);
}
ret
}
Confirmed an implementation based on a mutex, and another based on ring-channel
didn't panic
Metadata
Metadata
Assignees
Labels
No labels