fix the contention test

patch by @pftbest ❤️
This commit is contained in:
Jorge Aparicio 2017-11-09 16:54:30 +01:00
parent 40994962e2
commit ffcd423e67
2 changed files with 5 additions and 1 deletions

View File

@ -29,6 +29,10 @@ impl AtomicUsize {
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 {
unsafe { intrinsics::atomic_load_relaxed(self.v.get()) }
}

View File

@ -45,7 +45,7 @@ where
let n = rb.capacity() + 1;
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();
if head != tail {
let item = unsafe { ptr::read(buffer.get_unchecked(head)) };