Commit b1233937 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Avoid ambiguous call in futures

Summary:
[Folly] Avoid ambiguous call in futures. Because `std::atomic` is in `namespace std`, unqualified calls to `atomic_compare_exchange_strong_explicit` from within `namespace folly` are ADL-ambiguous between the overloads in `namespace std` and in `namespace folly`.

Also:
* Fix incorrectly-named prototype.
* Fix used of `std::atomic<T>::value_type` which may not exist.

Fixes #1221.

Reviewed By: aary, Orvid

Differential Revision: D17256763

fbshipit-source-id: ffcaf171e6257cdef29de0ffb63f310d7f4a93eb
parent 5ca43e12
......@@ -595,7 +595,7 @@ class Core final {
: State::OnlyCallback;
if (state == State::Start) {
if (atomic_compare_exchange_strong_explicit(
if (folly::atomic_compare_exchange_strong_explicit(
&state_,
&state,
nextState,
......@@ -633,7 +633,7 @@ class Core final {
auto state = state_.load(std::memory_order_acquire);
switch (state) {
case State::Start:
if (atomic_compare_exchange_strong_explicit(
if (folly::atomic_compare_exchange_strong_explicit(
&state_,
&state,
State::Proxy,
......@@ -687,7 +687,7 @@ class Core final {
auto state = state_.load(std::memory_order_acquire);
switch (state) {
case State::Start:
if (atomic_compare_exchange_strong_explicit(
if (folly::atomic_compare_exchange_strong_explicit(
&state_,
&state,
State::OnlyResult,
......
......@@ -65,8 +65,8 @@ constexpr std::memory_order atomic_compare_exchange_succ(
template <typename T>
bool atomic_compare_exchange_weak_explicit(
std::atomic<T>* obj,
typename std::atomic<T>::value_type* expected,
typename std::atomic<T>::value_type desired,
T* expected,
T desired,
std::memory_order succ,
std::memory_order fail) {
succ = detail::atomic_compare_exchange_succ(succ, fail);
......@@ -77,8 +77,8 @@ bool atomic_compare_exchange_weak_explicit(
template <typename T>
bool atomic_compare_exchange_strong_explicit(
std::atomic<T>* obj,
typename std::atomic<T>::value_type* expected,
typename std::atomic<T>::value_type desired,
T* expected,
T desired,
std::memory_order succ,
std::memory_order fail) {
succ = detail::atomic_compare_exchange_succ(succ, fail);
......
......@@ -30,8 +30,8 @@ namespace folly {
template <typename T>
bool atomic_compare_exchange_weak_explicit(
std::atomic<T>* obj,
typename std::atomic<T>::value_type* expected,
typename std::atomic<T>::value_type desired,
T* expected,
T desired,
std::memory_order succ,
std::memory_order fail);
......@@ -42,10 +42,10 @@ bool atomic_compare_exchange_weak_explicit(
//
// mimic: std::atomic_compare_exchange_strong
template <typename T>
bool atomic_compare_exchange_weak_explicit(
bool atomic_compare_exchange_strong_explicit(
std::atomic<T>* obj,
typename std::atomic<T>::value_type* expected,
typename std::atomic<T>::value_type desired,
T* expected,
T desired,
std::memory_order succ,
std::memory_order fail);
......
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