Skip to content
Snippets Groups Projects
Commit ffcd423e authored by Jorge Aparicio's avatar Jorge Aparicio
Browse files

fix the contention test

patch by @pftbest :heart:
parent 40994962
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,10 @@ impl AtomicUsize { ...@@ -29,6 +29,10 @@ impl AtomicUsize {
unsafe { &mut *self.v.get() } unsafe { &mut *self.v.get() }
} }
pub fn load_acquire(&self) -> usize {
unsafe { intrinsics::atomic_load_acq(self.v.get()) }
}
pub fn load_relaxed(&self) -> usize { pub fn load_relaxed(&self) -> usize {
unsafe { intrinsics::atomic_load_relaxed(self.v.get()) } unsafe { intrinsics::atomic_load_relaxed(self.v.get()) }
} }
......
...@@ -45,7 +45,7 @@ where ...@@ -45,7 +45,7 @@ where
let n = rb.capacity() + 1; let n = rb.capacity() + 1;
let buffer: &[T] = unsafe { rb.buffer.as_ref() }; let buffer: &[T] = unsafe { rb.buffer.as_ref() };
let tail = rb.tail.load_relaxed(); let tail = rb.tail.load_acquire();
let head = rb.head.load_relaxed(); let head = rb.head.load_relaxed();
if head != tail { if head != tail {
let item = unsafe { ptr::read(buffer.get_unchecked(head)) }; let item = unsafe { ptr::read(buffer.get_unchecked(head)) };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment