Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Go to the documentation of this file.
26 #ifndef JAU_ORDERED_ATOMIC_HPP_
27 #define JAU_ORDERED_ATOMIC_HPP_
36 #ifndef CXX_ALWAYS_INLINE
37 # define CXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
51 template <
typename _Tp, std::memory_order _MO>
struct ordered_atomic :
private std::atomic<_Tp> {
53 typedef std::atomic<_Tp> super;
67 operator _Tp() const noexcept
68 {
return super::load(_MO); }
71 operator _Tp() const volatile noexcept
72 {
return super::load(_MO); }
76 { super::store(__i, _MO);
return __i; }
80 { super::store(__i, _MO);
return __i; }
84 {
return super::fetch_add(1, _MO); }
88 {
return super::fetch_add(1, _MO); }
92 {
return super::fetch_sub(1, _MO); }
96 {
return super::fetch_sub(1, _MO); }
104 {
return __atomic_add_fetch(&_M_i, 1,
int(_MO)); }
108 {
return __atomic_add_fetch(&_M_i, 1,
int(_MO)); }
112 {
return __atomic_sub_fetch(&_M_i, 1,
int(_MO)); }
116 {
return __atomic_sub_fetch(&_M_i, 1,
int(_MO)); }
122 {
return super::is_lock_free(); }
126 {
return super::is_lock_free(); }
132 { super::store(__i, _MO); }
135 void store(_Tp __i)
volatile noexcept
136 { super::store(__i, _MO); }
140 {
return super::load(_MO); }
143 _Tp
load() const volatile noexcept
144 {
return super::load(_MO); }
148 {
return super::exchange(__i, _MO); }
152 {
return super::exchange(__i, _MO); }
156 {
return super::compare_exchange_weak(__e, __i, _MO); }
160 {
return super::compare_exchange_weak(__e, __i, _MO); }
164 {
return super::compare_exchange_strong(__e, __i, _MO); }
168 {
return super::compare_exchange_strong(__e, __i, _MO); }
172 {
return super::fetch_add(__i, _MO); }
176 {
return super::fetch_add(__i, _MO); }
180 {
return super::fetch_sub(__i, _MO); }
184 {
return super::fetch_sub(__i, _MO); }
188 {
return super::fetch_and(__i, _MO); }
192 {
return super::fetch_and(__i, _MO); }
196 {
return super::fetch_or(__i, _MO); }
200 {
return super::fetch_or(__i, _MO); }
204 {
return super::fetch_xor(__i, _MO); }
208 {
return super::fetch_xor(__i, _MO); }
CXX_ALWAYS_INLINE bool compare_exchange_strong(_Tp &__e, _Tp __i) noexcept
static constexpr bool is_always_lock_free
CXX_ALWAYS_INLINE _Tp fetch_add(_Tp __i) volatile noexcept
CXX_ALWAYS_INLINE _Tp exchange(_Tp __i) noexcept
ordered_atomic< int32_t, std::memory_order::memory_order_relaxed > relaxed_atomic_int32
Relaxed non-SC atomic integral scalar int32_t.
ordered_atomic< bool, std::memory_order::memory_order_relaxed > relaxed_atomic_bool
Relaxed non-SC atomic integral scalar boolean.
CXX_ALWAYS_INLINE _Tp operator--(int) noexcept
ordered_atomic< jau::snsize_t, std::memory_order::memory_order_seq_cst > sc_atomic_snsize_t
SC atomic integral scalar jau::snsize_t.
ordered_atomic< int32_t, std::memory_order::memory_order_seq_cst > sc_atomic_int32
SC atomic integral scalar int32_t.
CXX_ALWAYS_INLINE _Tp fetch_or(_Tp __i) noexcept
CXX_ALWAYS_INLINE void store(_Tp __i) noexcept
CXX_ALWAYS_INLINE _Tp fetch_sub(_Tp __i) noexcept
ordered_atomic< int64_t, std::memory_order::memory_order_seq_cst > sc_atomic_int64
SC atomic integral scalar int64_t.
CXX_ALWAYS_INLINE _Tp fetch_sub(_Tp __i) volatile noexcept
ordered_atomic< jau::nsize_t, std::memory_order::memory_order_seq_cst > sc_atomic_nsize_t
SC atomic integral scalar jau::nsize_t.
CXX_ALWAYS_INLINE bool compare_exchange_weak(_Tp &__e, _Tp __i) noexcept
CXX_ALWAYS_INLINE _Tp fetch_or(_Tp __i) volatile noexcept
ordered_atomic< int64_t, std::memory_order::memory_order_relaxed > relaxed_atomic_int64
Relaxed non-SC atomic integral scalar int64_t.
CXX_ALWAYS_INLINE _Tp exchange(_Tp __i) volatile noexcept
ordered_atomic() noexcept=default
ordered_atomic< int, std::memory_order::memory_order_seq_cst > sc_atomic_int
SC atomic integral scalar integer.
ordered_atomic< uint32_t, std::memory_order::memory_order_relaxed > relaxed_atomic_uint32
Relaxed non-SC atomic integral scalar uint32_t.
~sc_atomic_critical() noexcept
SC-DRF release via sc_atomic_bool::store()
sc_atomic_critical(sc_atomic_bool &sync) noexcept
SC-DRF acquire via sc_atomic_bool::load()
ordered_atomic< bool, std::memory_order::memory_order_seq_cst > sc_atomic_bool
SC atomic integral scalar boolean.
CXX_ALWAYS_INLINE _Tp fetch_and(_Tp __i) volatile noexcept
CXX_ALWAYS_INLINE _Tp load() const volatile noexcept
ordered_atomic< uint8_t, std::memory_order::memory_order_relaxed > relaxed_atomic_uint8
Relaxed non-SC atomic integral scalar uint8_t.
ordered_atomic< jau::nsize_t, std::memory_order::memory_order_relaxed > relaxed_atomic_nsize_t
Relaxed non-SC atomic integral scalar jau::nsize_t.
CXX_ALWAYS_INLINE _Tp fetch_and(_Tp __i) noexcept
std::atomic<T> type with predefined fixed std::memory_order, not allowing changing the memory model o...
CXX_ALWAYS_INLINE _Tp operator=(_Tp __i) noexcept
CXX_ALWAYS_INLINE bool is_lock_free() const noexcept
ordered_atomic< ssize_t, std::memory_order::memory_order_relaxed > relaxed_atomic_ssize_t
Relaxed non-SC atomic integral scalar ssize_t.
CXX_ALWAYS_INLINE _Tp load() const noexcept
ordered_atomic< int8_t, std::memory_order::memory_order_relaxed > relaxed_atomic_int8
Relaxed non-SC atomic integral scalar int8_t.
This class provides a RAII-style Sequentially Consistent (SC) data race free (DRF) critical block.
ordered_atomic< uint64_t, std::memory_order::memory_order_seq_cst > sc_atomic_uint64
SC atomic integral scalar uint64_t.
ordered_atomic< int16_t, std::memory_order::memory_order_seq_cst > sc_atomic_int16
SC atomic integral scalar int16_t.
ordered_atomic< uint32_t, std::memory_order::memory_order_seq_cst > sc_atomic_uint32
SC atomic integral scalar uint32_t.
ordered_atomic< int16_t, std::memory_order::memory_order_relaxed > relaxed_atomic_int16
Relaxed non-SC atomic integral scalar int16_t.
ordered_atomic< uint16_t, std::memory_order::memory_order_relaxed > relaxed_atomic_uint16
Relaxed non-SC atomic integral scalar uint16_t.
CXX_ALWAYS_INLINE _Tp fetch_xor(_Tp __i) noexcept
#define CXX_ALWAYS_INLINE
CXX_ALWAYS_INLINE _Tp operator++(int) volatile noexcept
CXX_ALWAYS_INLINE _Tp operator--(int) volatile noexcept
CXX_ALWAYS_INLINE _Tp operator=(_Tp __i) volatile noexcept
ordered_atomic< uint8_t, std::memory_order::memory_order_seq_cst > sc_atomic_uint8
SC atomic integral scalar uint8_t.
CXX_ALWAYS_INLINE bool compare_exchange_weak(_Tp &__e, _Tp __i) volatile noexcept
jau::ordered_atomic< ssize_t, std::memory_order::memory_order_seq_cst > sc_atomic_ssize_t
SC atomic integral scalar ssize_t.
ordered_atomic< std::size_t, std::memory_order::memory_order_relaxed > relaxed_atomic_size_t
Relaxed non-SC atomic integral scalar size_t.
CXX_ALWAYS_INLINE _Tp operator++(int) noexcept
CXX_ALWAYS_INLINE _Tp fetch_add(_Tp __i) noexcept
ordered_atomic< jau::snsize_t, std::memory_order::memory_order_relaxed > relaxed_atomic_snsize_t
Relaxed non-SC atomic integral scalar jau::snsize_t.
ordered_atomic< int8_t, std::memory_order::memory_order_seq_cst > sc_atomic_int8
SC atomic integral scalar int8_t.
ordered_atomic< int, std::memory_order::memory_order_relaxed > relaxed_atomic_int
Relaxed non-SC atomic integral scalar integer.
ordered_atomic< uint64_t, std::memory_order::memory_order_relaxed > relaxed_atomic_uint64
Relaxed non-SC atomic integral scalar uint64_t.
CXX_ALWAYS_INLINE bool is_lock_free() const volatile noexcept
sc_atomic_critical() noexcept=delete
CXX_ALWAYS_INLINE bool compare_exchange_strong(_Tp &__e, _Tp __i) volatile noexcept
ordered_atomic< std::size_t, std::memory_order::memory_order_seq_cst > sc_atomic_size_t
SC atomic integral scalar size_t.
CXX_ALWAYS_INLINE void store(_Tp __i) volatile noexcept
ordered_atomic< uint16_t, std::memory_order::memory_order_seq_cst > sc_atomic_uint16
SC atomic integral scalar uint16_t.
CXX_ALWAYS_INLINE _Tp fetch_xor(_Tp __i) volatile noexcept