fences.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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) 2011 Helge Bahmann
  7. * Copyright (c) 2013 Tim Blechmann
  8. * Copyright (c) 2014, 2025 Andrey Semashev
  9. */
  10. /*!
  11. * \file atomic/fences.hpp
  12. *
  13. * This header contains definition of \c atomic_thread_fence and \c atomic_signal_fence functions.
  14. */
  15. #ifndef BOOST_ATOMIC_FENCES_HPP_INCLUDED_
  16. #define BOOST_ATOMIC_FENCES_HPP_INCLUDED_
  17. #include <boost/memory_order.hpp>
  18. #include <boost/atomic/capabilities.hpp>
  19. #include <boost/atomic/detail/config.hpp>
  20. #include <boost/atomic/detail/fence_operations.hpp>
  21. #include <boost/atomic/detail/header.hpp>
  22. #ifdef BOOST_HAS_PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. /*
  26. * IMPLEMENTATION NOTE: All interface functions MUST be declared with BOOST_FORCEINLINE,
  27. * see comment for convert_memory_order_to_gcc in gcc_atomic_memory_order_utils.hpp.
  28. */
  29. namespace boost {
  30. namespace atomics {
  31. BOOST_FORCEINLINE void atomic_thread_fence(memory_order order) noexcept
  32. {
  33. atomics::detail::fence_operations::thread_fence(order);
  34. }
  35. BOOST_FORCEINLINE void atomic_signal_fence(memory_order order) noexcept
  36. {
  37. atomics::detail::fence_operations::signal_fence(order);
  38. }
  39. } // namespace atomics
  40. using atomics::atomic_thread_fence;
  41. using atomics::atomic_signal_fence;
  42. } // namespace boost
  43. #include <boost/atomic/detail/footer.hpp>
  44. #endif // BOOST_ATOMIC_FENCES_HPP_INCLUDED_