memory_order.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef BOOST_MEMORY_ORDER_HPP_INCLUDED
  2. #define BOOST_MEMORY_ORDER_HPP_INCLUDED
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. // boost/memory_order.hpp
  8. //
  9. // Defines enum boost::memory_order per the C++0x working draft
  10. //
  11. // Copyright (c) 2008, 2009 Peter Dimov
  12. //
  13. // Distributed under the Boost Software License, Version 1.0.
  14. // See accompanying file LICENSE_1_0.txt or copy at
  15. // http://www.boost.org/LICENSE_1_0.txt)
  16. namespace boost
  17. {
  18. //
  19. // Enum values are chosen so that code that needs to insert
  20. // a trailing fence for acquire semantics can use a single
  21. // test such as:
  22. //
  23. // if( mo & memory_order_acquire ) { ...fence... }
  24. //
  25. // For leading fences one can use:
  26. //
  27. // if( mo & memory_order_release ) { ...fence... }
  28. //
  29. // Architectures such as Alpha that need a fence on consume
  30. // can use:
  31. //
  32. // if( mo & ( memory_order_acquire | memory_order_consume ) ) { ...fence... }
  33. //
  34. // The values are also in the order of increasing "strength"
  35. // of the fences so that success/failure orders can be checked
  36. // efficiently in compare_exchange methods.
  37. //
  38. enum memory_order
  39. {
  40. memory_order_relaxed = 0,
  41. memory_order_consume = 1,
  42. memory_order_acquire = 2,
  43. memory_order_release = 4,
  44. memory_order_acq_rel = 6, // acquire | release
  45. memory_order_seq_cst = 14 // acq_rel | 8
  46. };
  47. } // namespace boost
  48. #endif // #ifndef BOOST_MEMORY_ORDER_HPP_INCLUDED