Skip to content

Commit

Permalink
Stop using atomic_thread_fence in SaturatingSemaphore
Browse files Browse the repository at this point in the history
Summary: Thread fences are not supported by TSAN

Reviewed By: yfeldblum

Differential Revision: D22056483

fbshipit-source-id: dfe5b462656605f2e659302125e248b287037629
  • Loading branch information
andriigrynenko authored and facebook-github-bot committed Jun 17, 2020
1 parent 23cadde commit b77dcf0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions folly/synchronization/SaturatingSemaphore.h
Expand Up @@ -20,6 +20,7 @@
#include <folly/detail/Futex.h>
#include <folly/detail/MemoryIdler.h>
#include <folly/portability/Asm.h>
#include <folly/synchronization/AtomicUtil.h>
#include <folly/synchronization/WaitOptions.h>
#include <folly/synchronization/detail/Spin.h>

Expand Down Expand Up @@ -302,14 +303,13 @@ FOLLY_NOINLINE bool SaturatingSemaphore<MayBlock, Atom>::tryWaitSlow(

auto before = state_.load(std::memory_order_relaxed);
while (before == NOTREADY &&
!state_.compare_exchange_strong(
before,
BLOCKED,
!folly::atomic_compare_exchange_weak_explicit<Atom>(
&state_,
&before,
static_cast<std::uint32_t>(BLOCKED),
std::memory_order_relaxed,
std::memory_order_relaxed)) {
std::memory_order_acquire)) {
if (before == READY) {
// TODO: move the acquire to the compare_exchange failure load after C++17
std::atomic_thread_fence(std::memory_order_acquire);
return true;
}
}
Expand Down

0 comments on commit b77dcf0

Please sign in to comment.