18 template <
typename Type>
21 std::atomic<Type> value;
31 :
Atomic(other.value.load()) {}
43 atomicOp(f, [](
const Type lhs,
const Type rhs) {
return lhs + rhs; });
48 atomicOp(f, [](
const Type lhs,
const Type rhs) {
return lhs - rhs; });
53 atomicOp(f, [](
const Type lhs,
const Type rhs) {
return lhs * rhs; });
59 atomicOp(f, [](
const Type lhs,
const Type rhs) {
return lhs / rhs; });
64 return value.load() + f;
68 return value.load() - f;
72 return value.load() * f;
77 return value.load() / f;
81 return value.load() == f;
85 return value.load() != f;
89 return value.load() > f;
93 return value.load() < f;
97 stream << f.value.load();
102 template <
typename TOp>
103 INLINE Type atomicOp(
const Type rhs,
const TOp& op) {
104 Type lhs = value.load();
105 Type desired = op(lhs, rhs);
106 while (!value.compare_exchange_weak(lhs, desired)) {
107 desired = op(lhs, rhs);
#define SPH_ASSERT(x,...)
Global parameters of the code.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Atomic value implemented using compare-exchange.
INLINE friend std::ostream & operator<<(std::ostream &stream, const Atomic &f)
INLINE bool operator>(const Type f) const
INLINE Type operator-(const Type f) const
INLINE Atomic(const Type f)
INLINE Type operator/(const Type f) const
INLINE Type operator+(const Type f) const
INLINE Atomic & operator-=(const Type f)
INLINE bool operator<(const Type f) const
INLINE Type operator*(const Type f) const
INLINE Atomic & operator*=(const Type f)
INLINE Atomic & operator/=(const Type f)
INLINE bool operator==(const Type f) const
INLINE Atomic & operator+=(const Type f)
INLINE bool operator!=(const Type f) const
INLINE Atomic(const Atomic &other)
INLINE Atomic & operator=(const Type f)