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