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@16
|
40
|
Chris@16
|
41 enum memory_order
|
Chris@16
|
42 {
|
Chris@16
|
43 memory_order_relaxed = 0,
|
Chris@16
|
44 memory_order_acquire = 1,
|
Chris@16
|
45 memory_order_release = 2,
|
Chris@16
|
46 memory_order_acq_rel = 3, // acquire | release
|
Chris@16
|
47 memory_order_seq_cst = 7, // acq_rel | 4
|
Chris@16
|
48 memory_order_consume = 8
|
Chris@16
|
49 };
|
Chris@16
|
50
|
Chris@16
|
51 } // namespace boost
|
Chris@16
|
52
|
Chris@16
|
53 #endif // #ifndef BOOST_MEMORY_ORDER_HPP_INCLUDED
|