HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SYS_AtomicInt< T > Class Template Reference

#include <SYS_AtomicInt.h>

Public Member Functions

 SYS_AtomicInt (T value=0)
 
 SYS_AtomicInt (SYS_EmptyConstructor)
 
T exchange (T val)
 
T exchangeAdd (T val)
 
T add (T val)
 Atomically adds val to myValue, returning the new value of myValue. More...
 
T maximum (T val)
 
T minimum (T val)
 
T compare_swap (T expected, T desired)
 
bool compareExchangeStrong (T &expected, T desired, SYS_MemoryOrder success=SYS_MEMORY_ORDER_SEQ_CST, SYS_MemoryOrder failure=SYS_MEMORY_ORDER_SEQ_CST)
 
bool compareExchangeWeak (T &expected, T desired, SYS_MemoryOrder success=SYS_MEMORY_ORDER_SEQ_CST, SYS_MemoryOrder failure=SYS_MEMORY_ORDER_SEQ_CST)
 
void store (T val, SYS_MemoryOrder order=SYS_MEMORY_ORDER_SEQ_CST)
 
T load (SYS_MemoryOrder order=SYS_MEMORY_ORDER_SEQ_CST) const
 
SYS_FORCE_INLINE T relaxedLoad () const
 
SYS_FORCE_INLINE void relaxedStore (T val)
 

Detailed Description

template<typename T>
class SYS_AtomicInt< T >

Definition at line 22 of file SYS_AtomicInt.h.

Constructor & Destructor Documentation

template<typename T>
SYS_AtomicInt< T >::SYS_AtomicInt ( T  value = 0)
inlineexplicit

Definition at line 25 of file SYS_AtomicInt.h.

template<typename T>
SYS_AtomicInt< T >::SYS_AtomicInt ( SYS_EmptyConstructor  )
inline

An empty constructor. This will initialize the value with garbage, unless used as a static object (in which case it will be guaranteed by the C++ standard to be initialized to zero). Only use if required to be set prior to other, dependent statically initialized objects.

Definition at line 31 of file SYS_AtomicInt.h.

Member Function Documentation

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::add ( T  val)
inline

Atomically adds val to myValue, returning the new value of myValue.

Definition at line 123 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::compare_swap ( T  expected,
T  desired 
)
inline

Atomically compares (myValue == expected), and if true, replaces myValue with desired. Returns the prior value.

Definition at line 162 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE bool SYS_AtomicInt< T >::compareExchangeStrong ( T expected,
T  desired,
SYS_MemoryOrder  success = SYS_MEMORY_ORDER_SEQ_CST,
SYS_MemoryOrder  failure = SYS_MEMORY_ORDER_SEQ_CST 
)
inline

Definition at line 170 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE bool SYS_AtomicInt< T >::compareExchangeWeak ( T expected,
T  desired,
SYS_MemoryOrder  success = SYS_MEMORY_ORDER_SEQ_CST,
SYS_MemoryOrder  failure = SYS_MEMORY_ORDER_SEQ_CST 
)
inline

Definition at line 183 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::exchange ( T  val)
inline

Atomically assigns val to myValue, returning the prior value of myValue.

Definition at line 109 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::exchangeAdd ( T  val)
inline

Atomically adds val to myValue, returning the prior value of myValue.

Definition at line 116 of file SYS_AtomicInt.h.

template<typename T >
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::load ( SYS_MemoryOrder  order = SYS_MEMORY_ORDER_SEQ_CST) const
inline
Precondition
The supplied order must be one of [RELAXED, LOAD, SEQ_CST].

Definition at line 209 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::maximum ( T  val)
inline

Atomically set myValue to the maximum of val and myValue. Returns the last known maximal value.

Definition at line 130 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::minimum ( T  val)
inline

Atomically set myValue to the minimum of val and myValue. Returns the last known minimal value.

Definition at line 146 of file SYS_AtomicInt.h.

template<typename T >
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::relaxedLoad ( ) const

Forced RELAXED memory load GCC has trouble inlining so we pull the definition up here.

Definition at line 216 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE void SYS_AtomicInt< T >::relaxedStore ( T  val)

Definition at line 223 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE void SYS_AtomicInt< T >::store ( T  val,
SYS_MemoryOrder  order = SYS_MEMORY_ORDER_SEQ_CST 
)
inline
Precondition
The supplied order must be one of [RELAXED, STORE, SEQ_CST].

Next two methods intentionally not marked as volatile as this would cause &myValue to evaluate to a pointer to a volatile myValue and that has implications on MSVC2005+ beyond the C++ spec.

This shouldn't be a problem unless somebody needs a volatile instance of SYS_AtomicInt<T>.

Definition at line 202 of file SYS_AtomicInt.h.


The documentation for this class was generated from the following file: