once_flag.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * Copyright (c) 2020 Andrey Semashev
  7. */
  8. /*!
  9. * \file atomic/detail/once_flag.hpp
  10. *
  11. * This header declares \c once_flag structure for controlling one time initialization
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_ONCE_FLAG_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_ONCE_FLAG_HPP_INCLUDED_
  15. #include <boost/atomic/detail/config.hpp>
  16. #include <boost/atomic/detail/aligned_variable.hpp>
  17. #include <boost/atomic/detail/core_operations.hpp>
  18. #include <boost/atomic/detail/header.hpp>
  19. #ifdef BOOST_HAS_PRAGMA_ONCE
  20. #pragma once
  21. #endif
  22. namespace boost {
  23. namespace atomics {
  24. namespace detail {
  25. typedef atomics::detail::core_operations< 1u, false, false > once_flag_operations;
  26. struct once_flag
  27. {
  28. BOOST_ATOMIC_DETAIL_ALIGNED_VAR(once_flag_operations::storage_alignment, once_flag_operations::storage_type, m_flag);
  29. };
  30. } // namespace detail
  31. } // namespace atomics
  32. } // namespace boost
  33. #include <boost/atomic/detail/footer.hpp>
  34. #endif // BOOST_ATOMIC_DETAIL_ONCE_FLAG_HPP_INCLUDED_