Commit 3d8f5dcd authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook GitHub Bot

Use folly::atomic_compare_exchange_strong_explicit in futures

Summary: This helps avoid TSAN false positives.

Reviewed By: yfeldblum

Differential Revision: D20787056

fbshipit-source-id: e62537235e3ad876e3ec5266f9c449d0d8340330
parent cdcefc75
...@@ -209,8 +209,9 @@ class DeferredExecutor final { ...@@ -209,8 +209,9 @@ class DeferredExecutor final {
} }
DCHECK(state == State::EMPTY); DCHECK(state == State::EMPTY);
func_ = std::move(func); func_ = std::move(func);
if (state_.compare_exchange_strong( if (folly::atomic_compare_exchange_strong_explicit(
state, &state_,
&state,
State::HAS_FUNCTION, State::HAS_FUNCTION,
std::memory_order_release, std::memory_order_release,
std::memory_order_acquire)) { std::memory_order_acquire)) {
...@@ -240,8 +241,9 @@ class DeferredExecutor final { ...@@ -240,8 +241,9 @@ class DeferredExecutor final {
executor_ = std::move(executor); executor_ = std::move(executor);
auto state = state_.load(std::memory_order_acquire); auto state = state_.load(std::memory_order_acquire);
if (state == State::EMPTY && if (state == State::EMPTY &&
state_.compare_exchange_strong( folly::atomic_compare_exchange_strong_explicit(
state, &state_,
&state,
State::HAS_EXECUTOR, State::HAS_EXECUTOR,
std::memory_order_release, std::memory_order_release,
std::memory_order_acquire)) { std::memory_order_acquire)) {
...@@ -269,8 +271,9 @@ class DeferredExecutor final { ...@@ -269,8 +271,9 @@ class DeferredExecutor final {
} }
auto state = state_.load(std::memory_order_acquire); auto state = state_.load(std::memory_order_acquire);
if (state == State::EMPTY && if (state == State::EMPTY &&
state_.compare_exchange_strong( folly::atomic_compare_exchange_strong_explicit(
state, &state_,
&state,
State::DETACHED, State::DETACHED,
std::memory_order_release, std::memory_order_release,
std::memory_order_acquire)) { std::memory_order_acquire)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment