/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include namespace folly { namespace detail { struct atomic_value_type_alias_ { template using apply = typename Atomic::value_type; }; struct atomic_value_type_load_ { template using apply = decltype(std::declval().load()); }; } // namespace detail // atomic_value_type_t // atomic_value_type // // A trait type alias and type giving the effective value-type of a type which // are atomic-like. Either member type alias value_type or the return type of // member function load. template using atomic_value_type_t = typename conditional_t< is_detected_v, detail::atomic_value_type_alias_, detail::atomic_value_type_load_>::template apply; template struct atomic_value_type { using type = atomic_value_type_t; }; /// memory_order_load /// /// The load part of a possibly-composite memory-order. constexpr std::memory_order memory_order_load( // std::memory_order order) noexcept; /// memory_order_store /// /// The store part of a possibly-composite memory-order. constexpr std::memory_order memory_order_store( std::memory_order order) noexcept; // atomic_compare_exchange_weak_explicit // // Fix TSAN bug in std::atomic_compare_exchange_weak_explicit. // Workaround for https://github.com/google/sanitizers/issues/970. // // mimic: std::atomic_compare_exchange_weak template