atomic.hpp
Go to the documentation of this file.
1 #ifndef BOOST_ATOMIC_HPP
2 #define BOOST_ATOMIC_HPP
3 
4 // Copyright (c) 2011 Helge Bahmann
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 #include <cstddef>
11 #include <boost/cstdint.hpp>
12 
14 #if !defined(BOOST_ATOMIC_FORCE_FALLBACK)
16 #endif
18 #include <boost/type_traits/is_signed.hpp>
19 
20 namespace boost {
21 
22 #ifndef BOOST_ATOMIC_CHAR_LOCK_FREE
23 #define BOOST_ATOMIC_CHAR_LOCK_FREE 0
24 #endif
25 
26 #ifndef BOOST_ATOMIC_CHAR16_T_LOCK_FREE
27 #define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 0
28 #endif
29 
30 #ifndef BOOST_ATOMIC_CHAR32_T_LOCK_FREE
31 #define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 0
32 #endif
33 
34 #ifndef BOOST_ATOMIC_WCHAR_T_LOCK_FREE
35 #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0
36 #endif
37 
38 #ifndef BOOST_ATOMIC_SHORT_LOCK_FREE
39 #define BOOST_ATOMIC_SHORT_LOCK_FREE 0
40 #endif
41 
42 #ifndef BOOST_ATOMIC_INT_LOCK_FREE
43 #define BOOST_ATOMIC_INT_LOCK_FREE 0
44 #endif
45 
46 #ifndef BOOST_ATOMIC_LONG_LOCK_FREE
47 #define BOOST_ATOMIC_LONG_LOCK_FREE 0
48 #endif
49 
50 #ifndef BOOST_ATOMIC_LLONG_LOCK_FREE
51 #define BOOST_ATOMIC_LLONG_LOCK_FREE 0
52 #endif
53 
54 #ifndef BOOST_ATOMIC_ADDRESS_LOCK_FREE
55 #define BOOST_ATOMIC_ADDRESS_LOCK_FREE 0
56 #endif
57 
58 #ifndef BOOST_ATOMIC_BOOL_LOCK_FREE
59 #define BOOST_ATOMIC_BOOL_LOCK_FREE 0
60 #endif
61 
62 #ifndef BOOST_ATOMIC_THREAD_FENCE
63 #define BOOST_ATOMIC_THREAD_FENCE 0
64 void
66 {
67 }
68 #endif
69 
70 #ifndef BOOST_ATOMIC_SIGNAL_FENCE
71 #define BOOST_ATOMIC_SIGNAL_FENCE 0
72 void
74 {
75  atomic_thread_fence(order);
76 }
77 #endif
78 
79 template<typename T>
80 class atomic : public detail::atomic::base_atomic<T, typename detail::atomic::type_classifier<T>::test, sizeof(T), boost::is_signed<T>::value > {
81 private:
82  typedef T value_type;
84 public:
85  atomic(void) : super() {}
86  explicit atomic(const value_type & v) : super(v) {}
87 
88  atomic & operator=(value_type v) volatile
89  {
91  return *const_cast<atomic *>(this);
92  }
93 private:
94  atomic(const atomic &) /* =delete */ ;
95  atomic & operator=(const atomic &) /* =delete */ ;
96 };
97 
115 #ifdef BOOST_HAS_LONG_LONG
118 #endif
121 
122 class atomic_flag {
123 public:
124  atomic_flag(void) : v_(false) {}
125 
126  bool
128  {
129  return v_.exchange(true, order);
130  }
131 
132  void
134  {
135  v_.store(false, order);
136  }
137 private:
138  atomic_flag(const atomic_flag &) /* = delete */ ;
139  atomic_flag & operator=(const atomic_flag &) /* = delete */ ;
141 };
142 
143 typedef atomic<char> atomic_char;
153 typedef atomic<int> atomic_int;
157 typedef atomic<long> atomic_long;
163 typedef atomic<bool> atomic_bool;
164 
165 }
166 
167 #endif
atomic< int32_t > atomic_int32_t
Definition: atomic.hpp:110
atomic< unsigned long long > atomic_ullong
Definition: atomic.hpp:160
Definition: base.hpp:116
atomic< uint16_t > atomic_uint16_t
Definition: atomic.hpp:105
static void atomic_signal_fence(memory_order)
Definition: gcc-armv6+.hpp:193
static void atomic_thread_fence(memory_order order)
Definition: gcc-armv6+.hpp:179
bool test_and_set(memory_order order=memory_order_seq_cst)
Definition: atomic.hpp:127
atomic< uint64_t > atomic_uint64_t
Definition: atomic.hpp:113
atomic & operator=(value_type v) volatile
Definition: atomic.hpp:88
atomic< bool > atomic_bool
Definition: atomic.hpp:120
atomic< long long > atomic_llong
Definition: atomic.hpp:161
atomic< short > atomic_short
Definition: atomic.hpp:104
atomic< unsigned short > atomic_ushort
Definition: atomic.hpp:103
atomic(const value_type &v)
Definition: atomic.hpp:86
atomic< uint8_t > atomic_uint8_t
Definition: atomic.hpp:101
atomic< int64_t > atomic_int64_t
Definition: atomic.hpp:114
atomic< unsigned int > atomic_uint
Definition: atomic.hpp:107
atomic< unsigned char > atomic_uchar
Definition: atomic.hpp:99
atomic(void)
Definition: atomic.hpp:85
atomic< bool > v_
Definition: atomic.hpp:140
atomic< int16_t > atomic_int16_t
Definition: atomic.hpp:106
atomic< int > atomic_int
Definition: atomic.hpp:108
atomic< uint32_t > atomic_uint32_t
Definition: atomic.hpp:109
atomic< long > atomic_long
Definition: atomic.hpp:112
void clear(memory_order order=memory_order_seq_cst) volatile
Definition: atomic.hpp:133
atomic< unsigned long > atomic_ulong
Definition: atomic.hpp:111
atomic< void * > atomic_address
Definition: atomic.hpp:119
atomic< signed char > atomic_schar
Definition: atomic.hpp:100
atomic< char > atomic_char
Definition: atomic.hpp:98
void operator=(const base_atomic &)
atomic< int8_t > atomic_int8_t
Definition: atomic.hpp:102


rosatomic
Author(s): Josh Faust
autogenerated on Fri Apr 5 2019 02:16:35