From b1dee749749347c7a329054fb6fde038e275ae67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Tue, 16 May 2023 11:19:33 +0200 Subject: [PATCH] Relax ordering of transition The first ordering of no operation relies on SeqCst semantics. All works with Acquire/Release semantics, so there is no reason to use the SeqCst ordering. The second ordering argument is for the failure, in which case we don't read any data, and therefore don't need any synchronization. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 82e2795..10f1a21 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -404,7 +404,7 @@ impl Channel { fn transition(&self, from: State, to: State) -> bool { self.state - .compare_exchange(from as u8, to as u8, Ordering::SeqCst, Ordering::SeqCst) + .compare_exchange(from as u8, to as u8, Ordering::AcqRel, Ordering::Relaxed) .is_ok() } }