From 17ae70ac07734f0c4b0fcd6aa7a845267e00ab66 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 27 Nov 2026 21:00:44 +0100 Subject: [PATCH] cultcache-rs: gate race test spawns its two writers directly Co-Authored-By: Claude Sonnet 5.5 --- packages/cultcache-rs/tests/unique_index.rs | 25 ++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/cultcache-rs/tests/unique_index.rs b/packages/cultcache-rs/tests/unique_index.rs index f6c67404..b4aa01fa 100644 --- a/packages/cultcache-rs/tests/unique_index.rs +++ b/packages/cultcache-rs/tests/unique_index.rs @@ -1086,21 +1086,20 @@ fn two_caches_racing_one_value_through_the_gate_leave_one_holder() { let value = format!("V{round}"); let gate = std::sync::Barrier::new(2); let (won_left, won_right) = std::thread::scope(|scope| { - let run = |cache: &mut CultCache, key: String| { - let (gate, value) = (&gate, &value); - scope.spawn(move || { - gate.wait(); - match cache.put(&key, &unique(value)) { - Ok(_) => true, - Err(error) => { - conflict_of(&error); - false - } + let (gate, value) = (&gate, &value); + let attempt = move |cache: &mut CultCache, key: String| { + gate.wait(); + match cache.put(&key, &unique(value)) { + Ok(_) => true, + Err(error) => { + conflict_of(&error); + false } - }) + } }; - let l = run(&mut left, format!("l{round}")); - let r = run(&mut right, format!("r{round}")); + let (left, right) = (&mut left, &mut right); + let l = scope.spawn(move || attempt(left, format!("l{round}"))); + let r = scope.spawn(move || attempt(right, format!("r{round}"))); (l.join().unwrap(), r.join().unwrap()) }); assert!(won_left ^ won_right, "{round}: exactly one writer lands (left {won_left}, right {won_right})");