Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Commit

Permalink
Turn a few Relaxed into Release to make tsan happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Stjepan Glavina committed Aug 9, 2018
1 parent 53aefe2 commit 64b174b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,10 @@ impl<T> Worker<T> {
atomic::fence(Ordering::Release);

// Increment the back index.
self.inner.back.store(b.wrapping_add(1), Ordering::Relaxed);
//
// This ordering could be `Relaxed`, but then thread sanitizer would falsely report data
// races because it doesn't understand fences.
self.inner.back.store(b.wrapping_add(1), Ordering::Release);
}

/// Pops an element from the deque.
Expand Down Expand Up @@ -759,8 +762,13 @@ impl<T> Stealer<T> {
return Steal::Retry;
}

atomic::fence(Ordering::Release);

// Success! Update the back index in the destination deque.
dest.inner.back.store(dest_b.wrapping_add(additional), Ordering::Relaxed);
//
// This ordering could be `Relaxed`, but then thread sanitizer would falsely report
// data races because it doesn't understand fences.
dest.inner.back.store(dest_b.wrapping_add(additional), Ordering::Release);

// Return the first stolen value.
Steal::Data(value)
Expand Down Expand Up @@ -819,8 +827,13 @@ impl<T> Stealer<T> {
f = f.wrapping_add(1);
dest_b = dest_b.wrapping_add(1);

atomic::fence(Ordering::Release);

// Update the destination back index.
dest.inner.back.store(dest_b, Ordering::Relaxed);
//
// This ordering could be `Relaxed`, but then thread sanitizer would falsely
// report data races because it doesn't understand fences.
dest.inner.back.store(dest_b, Ordering::Release);
}

// Return the first stolen value.
Expand Down

0 comments on commit 64b174b

Please sign in to comment.