From 11bc58a8302887e758e1f8af06ff31f0a76ee989 Mon Sep 17 00:00:00 2001 From: wang384670111 <384670111@qq.com> Date: Tue, 5 Mar 2024 10:02:40 +0800 Subject: [PATCH] modify memory ordering --- rayon-demo/src/tsp/solver.rs | 2 +- src/iter/par_bridge.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rayon-demo/src/tsp/solver.rs b/rayon-demo/src/tsp/solver.rs index 21c908b6e..f41c347ec 100644 --- a/rayon-demo/src/tsp/solver.rs +++ b/rayon-demo/src/tsp/solver.rs @@ -64,7 +64,7 @@ impl<'s> SolverCx<'s> { } pub fn tour_id(&self) -> TourId { - let counter = self.tour_counter.fetch_add(1, Ordering::SeqCst); + let counter = self.tour_counter.fetch_add(1, Ordering::Relaxed); TourId { id: counter } } diff --git a/src/iter/par_bridge.rs b/src/iter/par_bridge.rs index 9927f4f6b..5a139ad56 100644 --- a/src/iter/par_bridge.rs +++ b/src/iter/par_bridge.rs @@ -112,7 +112,7 @@ impl UnindexedProducer for &IterParallelProducer<'_, Iter // Check if the iterator is exhausted let update = self .split_count - .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |c| c.checked_sub(1)); + .fetch_update(Ordering::Relaxed, Ordering::Relaxed, |c| c.checked_sub(1)); (self, update.is_ok().then_some(self)) }