folly/folly/synchronization/AtomicStruct.h

/*
 * 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 <atomic>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <type_traits>

#include <folly/ConstexprMath.h>
#include <folly/Traits.h>
#include <folly/synchronization/detail/AtomicUtils.h>

namespace folly {

namespace detail {
template <size_t>
struct AtomicStructRaw;
template <>
struct AtomicStructRaw<0> {};
template <>
struct AtomicStructRaw<1> {};
template <>
struct AtomicStructRaw<2> {};
template <>
struct AtomicStructRaw<3> {};
} // namespace detail

/// AtomicStruct<T> work like C++ atomics, but can be used on any POD
/// type <= 8 bytes.
template <typename T, template <typename> class Atom = std::atomic>
class AtomicStruct {};

} // namespace folly