diff options
author | edef <edef@edef.eu> | 2024-10-19T11·17+0000 |
---|---|---|
committer | edef <edef@edef.eu> | 2024-10-19T13·49+0000 |
commit | 549c51f2004325e30c076f2f7c3e49e473a58d20 (patch) | |
tree | 8321649174fe1c13de60949a379aaba552352804 /users | |
parent | 25671c284ff8cecd1dd7e3a2a674e1ae92b3211d (diff) |
refactor(users/edef/weave): use swap rather than CAS r/8842
We only care about ordering on the same variable, and we rely on the release barrier provided by rayon's thread joining. The comparison failing is always an error path, and we're indifferent about which thread it fails on. Change-Id: I592a7eaae5b6935cf424c6576a49786f39909fb6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12666 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'users')
-rw-r--r-- | users/edef/weave/src/main.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/users/edef/weave/src/main.rs b/users/edef/weave/src/main.rs index e8a1990a0df3..243add9047a5 100644 --- a/users/edef/weave/src/main.rs +++ b/users/edef/weave/src/main.rs @@ -43,9 +43,11 @@ fn main() -> Result<()> { eprint!("… resolve roots\r"); ph_array.par_iter().enumerate().for_each(|(idx, h)| { if let Some(idx_slot) = roots.find(h) { - idx_slot - .compare_exchange(INDEX_NULL, idx as u32, Ordering::SeqCst, Ordering::SeqCst) - .expect("duplicate entry"); + assert_eq!( + idx_slot.swap(idx as u32, Ordering::Relaxed), + INDEX_NULL, + "duplicate entry" + ); } }); eprintln!("{DONE}"); |