Commit df460658 authored by Songqiao Su's avatar Songqiao Su Committed by Facebook GitHub Bot

(folly/coro) using atomic_compare_exchange_weak_explicit in coro::Baton

Summary:
to avoid hit TSAN issue when using coro::Baton

(Note: this ignores all push blocking failures!)

Reviewed By: lewissbaker

Differential Revision: D22192037

fbshipit-source-id: ee35179be79deb1d3b79b7b432c8a65c793f7d8f
parent 8a3d5b9c
......@@ -19,6 +19,7 @@
#if FOLLY_HAS_COROUTINES
#include <folly/experimental/coro/Baton.h>
#include <folly/synchronization/AtomicUtil.h>
#include <cassert>
#include <utility>
......@@ -56,8 +57,12 @@ bool Baton::waitImpl(WaitOperation* awaiter) const noexcept {
return false;
}
awaiter->next_ = static_cast<WaitOperation*>(oldValue);
} while (!state_.compare_exchange_weak(
oldValue, awaiter, std::memory_order_release, std::memory_order_acquire));
} while (!folly::atomic_compare_exchange_weak_explicit(
&state_,
&oldValue,
static_cast<void*>(awaiter),
std::memory_order_release,
std::memory_order_acquire));
return true;
}
......
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