Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:10:39

0001 //  boost/memory_order.hpp
0002 //
0003 //  Defines enum boost::memory_order per the C++0x working draft
0004 //
0005 //  Copyright (c) 2008, 2009 Peter Dimov
0006 //  Copyright (c) 2018 Andrey Semashev
0007 //
0008 //  Distributed under the Boost Software License, Version 1.0.
0009 //  See accompanying file LICENSE_1_0.txt or copy at
0010 //  http://www.boost.org/LICENSE_1_0.txt)
0011 
0012 #ifndef BOOST_MEMORY_ORDER_HPP_INCLUDED
0013 #define BOOST_MEMORY_ORDER_HPP_INCLUDED
0014 
0015 #include <boost/config.hpp>
0016 
0017 #if defined(BOOST_HAS_PRAGMA_ONCE)
0018 # pragma once
0019 #endif
0020 
0021 namespace boost
0022 {
0023 
0024 //
0025 // Enum values are chosen so that code that needs to insert
0026 // a trailing fence for acquire semantics can use a single
0027 // test such as:
0028 //
0029 // if( mo & memory_order_acquire ) { ...fence... }
0030 //
0031 // For leading fences one can use:
0032 //
0033 // if( mo & memory_order_release ) { ...fence... }
0034 //
0035 // Architectures such as Alpha that need a fence on consume
0036 // can use:
0037 //
0038 // if( mo & ( memory_order_acquire | memory_order_consume ) ) { ...fence... }
0039 //
0040 // The values are also in the order of increasing "strength"
0041 // of the fences so that success/failure orders can be checked
0042 // efficiently in compare_exchange methods.
0043 //
0044 
0045 #if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
0046 
0047 enum class memory_order : unsigned int
0048 {
0049     relaxed = 0,
0050     consume = 1,
0051     acquire = 2,
0052     release = 4,
0053     acq_rel = 6, // acquire | release
0054     seq_cst = 14 // acq_rel | 8
0055 };
0056 
0057 BOOST_INLINE_VARIABLE BOOST_CONSTEXPR_OR_CONST memory_order memory_order_relaxed = memory_order::relaxed;
0058 BOOST_INLINE_VARIABLE BOOST_CONSTEXPR_OR_CONST memory_order memory_order_consume = memory_order::consume;
0059 BOOST_INLINE_VARIABLE BOOST_CONSTEXPR_OR_CONST memory_order memory_order_acquire = memory_order::acquire;
0060 BOOST_INLINE_VARIABLE BOOST_CONSTEXPR_OR_CONST memory_order memory_order_release = memory_order::release;
0061 BOOST_INLINE_VARIABLE BOOST_CONSTEXPR_OR_CONST memory_order memory_order_acq_rel = memory_order::acq_rel;
0062 BOOST_INLINE_VARIABLE BOOST_CONSTEXPR_OR_CONST memory_order memory_order_seq_cst = memory_order::seq_cst;
0063 
0064 #undef BOOST_MEMORY_ORDER_INLINE_VARIABLE
0065 
0066 #else // !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
0067 
0068 enum memory_order
0069 {
0070     memory_order_relaxed = 0,
0071     memory_order_consume = 1,
0072     memory_order_acquire = 2,
0073     memory_order_release = 4,
0074     memory_order_acq_rel = 6, // acquire | release
0075     memory_order_seq_cst = 14 // acq_rel | 8
0076 };
0077 
0078 #endif // !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
0079 
0080 } // namespace boost
0081 
0082 #endif // #ifndef BOOST_MEMORY_ORDER_HPP_INCLUDED