9 #ifndef _STRUS_ATOMIC_HPP_INCLUDED 
   10 #define _STRUS_ATOMIC_HPP_INCLUDED 
   14 #define STRUS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 
   17 #undef STRUS_USE_STD_ATOMIC 
   18 #if __cplusplus >= 201103L 
   20 #define STRUS_USE_STD_ATOMIC 
   21 #elif defined __GNUC__ 
   22 #if STRUS_GCC_VERSION >= 40900 
   23 #define STRUS_USE_STD_ATOMIC 
   24 #endif // STRUS_GCC_VERSION 
   28 #ifdef STRUS_USE_STD_ATOMIC 
   36         :
public std::atomic<X>
 
   47 #define STRUS_MEMORY_ORDER_ATOMIC_COUNTER std::memory_order_acquire 
   49 #else //STRUS_USE_STD_ATOMIC 
   50 #include <boost/atomic.hpp> 
   56         :
public boost::atomic<X>
 
   67 #define STRUS_MEMORY_ORDER_ATOMIC_COUNTER boost::memory_order_acquire 
   69 #endif //STRUS_USE_STD_ATOMIC 
   73 template <
typename IntegralCounterType>
 
   80                 :strus::
atomic<IntegralCounterType>(initialValue_)
 
  111         void set( 
const IntegralCounterType& val)
 
  120         bool test_and_set( IntegralCounterType testval, IntegralCounterType newval)
 
  132                 :strus::
atomic<bool>(initialValue_)
 
  139                 bool prev_val = !val;
 
void set(const IntegralCounterType &val)
Initialization of the counter. 
Definition: atomic.hpp:111
bool set(bool val)
Set the flag, if the new value changes the current value. 
Definition: atomic.hpp:137
Definition: atomic.hpp:74
atomic(const atomic &o)
Definition: atomic.hpp:61
void decrement(IntegralCounterType val=1)
Decrement of the counter. 
Definition: atomic.hpp:90
IntegralCounterType allocIncrement(IntegralCounterType val=1)
Increment of the counter. 
Definition: atomic.hpp:97
atomic(X value)
Definition: atomic.hpp:59
bool test() const 
Evaluate the current value. 
Definition: atomic.hpp:145
bool test_and_set(IntegralCounterType testval, IntegralCounterType newval)
Compare current value with 'testval', change it to 'newval' if matches. 
Definition: atomic.hpp:120
Definition: atomic.hpp:126
#define STRUS_MEMORY_ORDER_ATOMIC_COUNTER
Definition: atomic.hpp:67
Definition: atomic.hpp:55
IntegralCounterType value() const 
Increment of the counter. 
Definition: atomic.hpp:104
AtomicCounter(IntegralCounterType initialValue_=0)
Constructor. 
Definition: atomic.hpp:79
AtomicFlag(bool initialValue_=false)
Constructor. 
Definition: atomic.hpp:131
void increment(IntegralCounterType val=1)
Increment of the counter. 
Definition: atomic.hpp:84