atomic.hpp
Go to the documentation of this file.
00001 #ifndef BOOST_ATOMIC_HPP
00002 #define BOOST_ATOMIC_HPP
00003 
00004 //  Copyright (c) 2011 Helge Bahmann
00005 //
00006 //  Distributed under the Boost Software License, Version 1.0.
00007 //  See accompanying file LICENSE_1_0.txt or copy at
00008 //  http://www.boost.org/LICENSE_1_0.txt)
00009 
00010 #include <cstddef>
00011 #include <boost/cstdint.hpp>
00012 
00013 #include <boost/atomic/detail/base.hpp>
00014 #if !defined(BOOST_ATOMIC_FORCE_FALLBACK)
00015 #include <boost/atomic/platform.hpp>
00016 #endif
00017 #include <boost/atomic/detail/type-classifier.hpp>
00018 #include <boost/type_traits/is_signed.hpp>
00019 
00020 namespace boost {
00021 
00022 #ifndef BOOST_ATOMIC_CHAR_LOCK_FREE
00023 #define BOOST_ATOMIC_CHAR_LOCK_FREE 0
00024 #endif
00025 
00026 #ifndef BOOST_ATOMIC_CHAR16_T_LOCK_FREE
00027 #define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 0
00028 #endif
00029 
00030 #ifndef BOOST_ATOMIC_CHAR32_T_LOCK_FREE
00031 #define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 0
00032 #endif
00033 
00034 #ifndef BOOST_ATOMIC_WCHAR_T_LOCK_FREE
00035 #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0
00036 #endif
00037 
00038 #ifndef BOOST_ATOMIC_SHORT_LOCK_FREE
00039 #define BOOST_ATOMIC_SHORT_LOCK_FREE 0
00040 #endif
00041 
00042 #ifndef BOOST_ATOMIC_INT_LOCK_FREE
00043 #define BOOST_ATOMIC_INT_LOCK_FREE 0
00044 #endif
00045 
00046 #ifndef BOOST_ATOMIC_LONG_LOCK_FREE
00047 #define BOOST_ATOMIC_LONG_LOCK_FREE 0
00048 #endif
00049 
00050 #ifndef BOOST_ATOMIC_LLONG_LOCK_FREE
00051 #define BOOST_ATOMIC_LLONG_LOCK_FREE 0
00052 #endif
00053 
00054 #ifndef BOOST_ATOMIC_ADDRESS_LOCK_FREE
00055 #define BOOST_ATOMIC_ADDRESS_LOCK_FREE 0
00056 #endif
00057 
00058 #ifndef BOOST_ATOMIC_BOOL_LOCK_FREE
00059 #define BOOST_ATOMIC_BOOL_LOCK_FREE 0
00060 #endif
00061 
00062 #ifndef BOOST_ATOMIC_THREAD_FENCE
00063 #define BOOST_ATOMIC_THREAD_FENCE 0
00064 void
00065 atomic_thread_fence(memory_order)
00066 {
00067 }
00068 #endif
00069 
00070 #ifndef BOOST_ATOMIC_SIGNAL_FENCE
00071 #define BOOST_ATOMIC_SIGNAL_FENCE 0
00072 void
00073 atomic_signal_fence(memory_order order)
00074 {
00075         atomic_thread_fence(order);
00076 }
00077 #endif
00078 
00079 template<typename T>
00080 class atomic : public detail::atomic::base_atomic<T, typename detail::atomic::type_classifier<T>::test, sizeof(T), boost::is_signed<T>::value > {
00081 private:
00082         typedef T value_type;
00083         typedef detail::atomic::base_atomic<T, typename detail::atomic::type_classifier<T>::test, sizeof(T), boost::is_signed<T>::value > super;
00084 public:
00085         atomic(void) : super() {}
00086         explicit atomic(const value_type & v) : super(v) {}
00087         
00088         atomic & operator=(value_type v) volatile
00089         {
00090                 super::operator=(v);
00091                 return *const_cast<atomic *>(this);
00092         }
00093 private:
00094         atomic(const atomic &) /* =delete */ ;
00095         atomic & operator=(const atomic &) /* =delete */ ;
00096 };
00097 
00098 typedef atomic<char> atomic_char;
00099 typedef atomic<unsigned char> atomic_uchar;
00100 typedef atomic<signed char> atomic_schar;
00101 typedef atomic<uint8_t> atomic_uint8_t;
00102 typedef atomic<int8_t> atomic_int8_t;
00103 typedef atomic<unsigned short> atomic_ushort;
00104 typedef atomic<short> atomic_short;
00105 typedef atomic<uint16_t> atomic_uint16_t;
00106 typedef atomic<int16_t> atomic_int16_t;
00107 typedef atomic<unsigned int> atomic_uint;
00108 typedef atomic<int> atomic_int;
00109 typedef atomic<uint32_t> atomic_uint32_t;
00110 typedef atomic<int32_t> atomic_int32_t;
00111 typedef atomic<unsigned long> atomic_ulong;
00112 typedef atomic<long> atomic_long;
00113 typedef atomic<uint64_t> atomic_uint64_t;
00114 typedef atomic<int64_t> atomic_int64_t;
00115 #ifdef BOOST_HAS_LONG_LONG
00116 typedef atomic<unsigned long long> atomic_ullong;
00117 typedef atomic<long long> atomic_llong;
00118 #endif
00119 typedef atomic<void*> atomic_address;
00120 typedef atomic<bool> atomic_bool;
00121 
00122 class atomic_flag {
00123 public:
00124         atomic_flag(void) : v_(false) {}
00125         
00126         bool
00127         test_and_set(memory_order order = memory_order_seq_cst)
00128         {
00129                 return v_.exchange(true, order);
00130         }
00131         
00132         void
00133         clear(memory_order order = memory_order_seq_cst) volatile
00134         {
00135                 v_.store(false, order);
00136         }
00137 private:
00138         atomic_flag(const atomic_flag &) /* = delete */ ;
00139         atomic_flag & operator=(const atomic_flag &) /* = delete */ ;
00140         atomic<bool> v_;
00141 };
00142 
00143 typedef atomic<char> atomic_char;
00144 typedef atomic<unsigned char> atomic_uchar;
00145 typedef atomic<signed char> atomic_schar;
00146 typedef atomic<uint8_t> atomic_uint8_t;
00147 typedef atomic<int8_t> atomic_int8_t;
00148 typedef atomic<unsigned short> atomic_ushort;
00149 typedef atomic<short> atomic_short;
00150 typedef atomic<uint16_t> atomic_uint16_t;
00151 typedef atomic<int16_t> atomic_int16_t;
00152 typedef atomic<unsigned int> atomic_uint;
00153 typedef atomic<int> atomic_int;
00154 typedef atomic<uint32_t> atomic_uint32_t;
00155 typedef atomic<int32_t> atomic_int32_t;
00156 typedef atomic<unsigned long> atomic_ulong;
00157 typedef atomic<long> atomic_long;
00158 typedef atomic<uint64_t> atomic_uint64_t;
00159 typedef atomic<int64_t> atomic_int64_t;
00160 typedef atomic<unsigned long long> atomic_ullong;
00161 typedef atomic<long long> atomic_llong;
00162 typedef atomic<void*> atomic_address;
00163 typedef atomic<bool> atomic_bool;
00164 
00165 }
00166 
00167 #endif


rosatomic
Author(s): Josh Faust
autogenerated on Sat Jun 8 2019 20:43:34