mn_atomic.hpp
Go to the documentation of this file.
1 
20 #ifndef _MINLIB_08365b25_a93f_4c7e_81f8_38958486f7b2_H_
21 #define _MINLIB_08365b25_a93f_4c7e_81f8_38958486f7b2_H_
22 
23 #include "mn_config.hpp"
24 
25 #include <stdint.h>
26 
27 #include "mn_def.hpp"
30 
31 
32 namespace mn {
33 
34 
35  template<typename T>
37 
38 
39  // Signad basic types
58 
59  // unsigned types
76 
77 
78  // Spzial types
89 
90  template <typename TAtomicType, TAtomicType TTrue = true, TAtomicType TFalse = false>
92  public:
93  using flag_type = TAtomicType;
94  using reference = TAtomicType&;
95 
96  constexpr basic_atomic_flag() noexcept
97  : m_bFlag(0) { }
98 
99  constexpr basic_atomic_flag(const flag_type& flag) noexcept
100  : m_bFlag(flag) { }
101 
102  basic_atomic_flag(const basic_atomic_flag&) noexcept = delete;
103 
104  reference operator=(const reference) noexcept = delete;
105  reference operator=(const reference) volatile noexcept = delete;
106 
108  m_bFlag.store(TFalse, order);
109  }
111  return m_bFlag.exchange(TTrue, order);
112  }
114  return m_bFlag.load(order);
115  }
116  private:
118  };
119 
121 }
122 
123 
124 #endif
Definition: mn_atomic.hpp:91
basic_atomic_flag(const basic_atomic_flag &) noexcept=delete
reference operator=(const reference) noexcept=delete
constexpr basic_atomic_flag(const flag_type &flag) noexcept
Definition: mn_atomic.hpp:99
flag_type test(memory_order order=memory_order::SeqCst) const
Definition: mn_atomic.hpp:113
void clear(memory_order order=memory_order::SeqCst) noexcept
Definition: mn_atomic.hpp:107
_atomic< flag_type > m_bFlag
Definition: mn_atomic.hpp:117
TAtomicType flag_type
Definition: mn_atomic.hpp:93
reference operator=(const reference) volatile noexcept=delete
constexpr basic_atomic_flag() noexcept
Definition: mn_atomic.hpp:96
TAtomicType & reference
Definition: mn_atomic.hpp:94
flag_type test_and_set(memory_order order=memory_order::SeqCst) noexcept
Definition: mn_atomic.hpp:110
order
Definition: mn_endianness.hpp:28
Definition: mn_allocator_typetraits.hpp:25
memory_order
Definition: mn_atomic_flags.hpp:41
Special version for bool.
Definition: mn_atomic_primary_types.hpp:55
Special version for char16_t.
Definition: mn_atomic_primary_types.hpp:298
Special version for char32_t.
Definition: mn_atomic_primary_types.hpp:320
Special version for char.
Definition: mn_atomic_primary_types.hpp:77
Special version for int.
Definition: mn_atomic_primary_types.hpp:143
Special version for long.
Definition: mn_atomic_primary_types.hpp:165
Special version for short.
Definition: mn_atomic_primary_types.hpp:121
Special version for signed char.
Definition: mn_atomic_primary_types.hpp:99
Special version for unsigned char.
Definition: mn_atomic_primary_types.hpp:210
Special version for int.
Definition: mn_atomic_primary_types.hpp:254
Special version for long.
Definition: mn_atomic_primary_types.hpp:276
Special version for short.
Definition: mn_atomic_primary_types.hpp:232
Special version for wchar_t.
Definition: mn_atomic_primary_types.hpp:342
Special version for pointer.
Definition: mn_atomic_primary_types.hpp:364
Only for declar special version for types.
Definition: mn_atomic_primary_types.hpp:43