fences.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 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/operations.hpp>
  20. #ifdef BOOST_HAS_PRAGMA_ONCE
  21. #pragma once
  22. #endif
  23. /*
  24. * IMPLEMENTATION NOTE: All interface functions MUST be declared with BOOST_FORCEINLINE,
  25. * see comment for convert_memory_order_to_gcc in ops_gcc_atomic.hpp.
  26. */
  27. namespace boost {
  28. namespace atomics {
  29. #if BOOST_ATOMIC_THREAD_FENCE > 0
  30. BOOST_FORCEINLINE void atomic_thread_fence(memory_order order) BOOST_NOEXCEPT
  31. {
  32. detail::thread_fence(order);
  33. }
  34. #else
  35. BOOST_FORCEINLINE void atomic_thread_fence(memory_order) BOOST_NOEXCEPT
  36. {
  37. detail::lockpool::thread_fence();
  38. }
  39. #endif
  40. #if BOOST_ATOMIC_SIGNAL_FENCE > 0
  41. BOOST_FORCEINLINE void atomic_signal_fence(memory_order order) BOOST_NOEXCEPT
  42. {
  43. detail::signal_fence(order);
  44. }
  45. #else
  46. BOOST_FORCEINLINE void atomic_signal_fence(memory_order) BOOST_NOEXCEPT
  47. {
  48. detail::lockpool::signal_fence();
  49. }
  50. #endif
  51. } // namespace atomics
  52. using atomics::atomic_thread_fence;
  53. using atomics::atomic_signal_fence;
  54. } // namespace boost
  55. #endif // BOOST_ATOMIC_FENCES_HPP_INCLUDED_