17 #ifndef AGX_ATOMICVALUE_H 18 #define AGX_ATOMICVALUE_H 20 #include <agx/config/AGX_DEBUG_SYNCHRONIZATION_OVERHEAD_TESTING.h> 50 inline T
set(T value);
62 inline T
add(T value);
68 inline T
sub(T value);
92 #if !AGX_DEBUG_SYNCHRONIZATION_OVERHEAD_TESTING() 93 std::atomic< T > m_value;
109 inline std::ostream& operator << ( std::ostream& stream, const AtomicValueT<T>& value )
111 stream << value.
get();
117 #if !(defined(AGX_APPLE_IOS) || (AGX_DEBUG_SYNCHRONIZATION_OVERHEAD_TESTING())) 127 m_value.store( av.m_value.load() );
133 m_value.store( rhs.m_value.load() );
146 return m_value.exchange( value );
160 return m_value.fetch_add( value );
166 return m_value.fetch_sub( value );
172 return m_value.fetch_add( 1 );
178 return m_value.fetch_sub( 1 );
184 return m_value.compare_exchange_strong( test, newValue );
196 m_value = av.m_value;
202 m_value = rhs.m_value;
257 return this->add(-1);
AtomicValueT template for integral types, all operations are atomic.
T sub(T value)
Subtract a value.
T get() const
Get the current value.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
T inc()
Increment the value.
T dec()
Decrement the value.
T compareAndSet(T test, T newValue)
Compares the current value with a test value and if they are equal the value is replaced by a new val...
T add(T value)
Add a value.
AtomicValueT< T > & operator=(const agx::AtomicValueT< T > &rhs)
AtomicValueT(T initialValue=0)