Skip to content

Commit

Permalink
Use stronger hold ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
agerasev committed Feb 3, 2024
1 parent 195bda6 commit a68d1ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/rb/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ impl<S: Storage + ?Sized> Observer for SharedRb<S> {

#[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)
}
}

Expand All @@ -133,11 +133,11 @@ impl<S: Storage + ?Sized> Consumer for SharedRb<S> {
impl<S: Storage + ?Sized> RingBuffer for SharedRb<S> {
#[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)
}
}

Expand Down

0 comments on commit a68d1ff

Please sign in to comment.