11 #ifndef __SYS_AtomicInt__
12 #define __SYS_AtomicInt__
81 std::atomic<T> myValue;
90 explicit operator T()
const;
98 #if defined(AMD64) || defined(ARM64)
104 template <
typename T>
107 template <typename T>
111 return myValue.exchange(val);
114 template <
typename T>
118 return myValue.fetch_add(val);
121 template <
typename T>
125 return (myValue += val);
128 template <
typename T>
132 T me = relaxedLoad();
139 while (!compareExchangeWeak(me, val));
144 template <
typename T>
148 T me = relaxedLoad();
155 while (!compareExchangeWeak(me, val));
160 template <
typename T>
164 compareExchangeStrong(expected, desired);
168 template <
typename T>
176 return myValue.compare_exchange_strong(
177 expected, desired, sysToStdMemoryOrder(success),
178 sysToStdMemoryOrder(failure));
181 template <
typename T>
189 return myValue.compare_exchange_weak(
190 expected, desired, sysToStdMemoryOrder(success),
191 sysToStdMemoryOrder(failure));
200 template <
typename T>
204 myValue.store(val, sysToStdMemoryOrder(order));
207 template <
typename T>
211 return myValue.load(sysToStdMemoryOrder(order));
214 template <
typename T>
218 return myValue.load(std::memory_order_relaxed);
221 template <
typename T>
225 myValue.store(val, std::memory_order_relaxed);
228 template <
typename T>
232 std::memory_order std_order = std::memory_order_seq_cst;
#define SYS_DECLARE_LEGACY_TR_TEMPLATE(...)
Version for class template.
SYS_FORCE_INLINE void relaxedStore(T val)
SYS_AtomicInt< int32 > SYS_AtomicInt32
void store(T val, SYS_MemoryOrder order=SYS_MEMORY_ORDER_SEQ_CST)
SYS_AtomicInt(SYS_EmptyConstructor)
bool compareExchangeStrong(T &expected, T desired, SYS_MemoryOrder success=SYS_MEMORY_ORDER_SEQ_CST, SYS_MemoryOrder failure=SYS_MEMORY_ORDER_SEQ_CST)
T load(SYS_MemoryOrder order=SYS_MEMORY_ORDER_SEQ_CST) const
bool compareExchangeWeak(T &expected, T desired, SYS_MemoryOrder success=SYS_MEMORY_ORDER_SEQ_CST, SYS_MemoryOrder failure=SYS_MEMORY_ORDER_SEQ_CST)
#define SYS_ATOMIC_INLINE
T compare_swap(T expected, T desired)
SYS_AtomicInt< int64 > SYS_AtomicInt64
GLdouble GLdouble GLint GLint order
Any reordering the compiler or hardware chooses to do is okay.
SYS_FORCE_INLINE T relaxedLoad() const
SYS_AtomicInt< int32 > SYS_AtomicCounter
VULKAN_HPP_CONSTEXPR_14 VULKAN_HPP_INLINE T exchange(T &obj, U &&newValue)
T add(T val)
Atomically adds val to myValue, returning the new value of myValue.