From a68d1ff653ab67efdb3b01e79ee8201fc7a11a78 Mon Sep 17 00:00:00 2001 From: Alexey Gerasev Date: Sat, 3 Feb 2024 11:48:14 +0700 Subject: [PATCH] Use stronger hold ordering --- src/rb/shared.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rb/shared.rs b/src/rb/shared.rs index 4afb72a..c73cba6 100644 --- a/src/rb/shared.rs +++ b/src/rb/shared.rs @@ -108,11 +108,11 @@ impl Observer for SharedRb { #[inline] fn read_is_held(&self) -> bool { - self.read_held.load(Ordering::Relaxed) + self.read_held.load(Ordering::Acquire) } #[inline] fn write_is_held(&self) -> bool { - self.write_held.load(Ordering::Relaxed) + self.write_held.load(Ordering::Acquire) } } @@ -133,11 +133,11 @@ impl Consumer for SharedRb { impl RingBuffer for SharedRb { #[inline] unsafe fn hold_read(&self, flag: bool) -> bool { - self.read_held.swap(flag, Ordering::Relaxed) + self.read_held.swap(flag, Ordering::AcqRel) } #[inline] unsafe fn hold_write(&self, flag: bool) -> bool { - self.write_held.swap(flag, Ordering::Relaxed) + self.write_held.swap(flag, Ordering::AcqRel) } }