#[path = "common/mod.rs"]
mod common;
use interweave::{Atomic, World};
fn indexer(world: &mut World, num_threads: usize) {
let table: Vec<Atomic<i32>> = (0..128).map(|i| world.atomic(format!("t{i}"), 0)).collect();
for tid in 0..num_threads {
let table = table.clone();
world.spawn(format!("thread-{tid}"), async move {
for m in 1..=4 {
let w = m * 11 + tid as i32;
let mut h = ((w * 7) % 128) as usize;
while table[h].compare_exchange(0, w).await.is_err() {
h = (h + 1) % 128;
}
}
Ok(())
});
}
}
fn main() {
let n = common::size(12);
let counts = common::explore_counts(move |w| indexer(w, n));
println!(
"indexer({n}): traces={}, states={}",
counts.traces, counts.states
);
}