From 3f6f6bf7ab75abf92ef2ef44c3327f59e238130a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 14 Aug 2012 03:11:17 +0000 Subject: Add atomic comparison operators. git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4684 a436a847-0d15-0410-975c-d299462d15a1 --- raul/AtomicInt.hpp | 5 +++++ raul/AtomicPtr.hpp | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'raul') diff --git a/raul/AtomicInt.hpp b/raul/AtomicInt.hpp index 2fd624c..172af6b 100644 --- a/raul/AtomicInt.hpp +++ b/raul/AtomicInt.hpp @@ -51,6 +51,11 @@ public: inline int operator+(int val) const { return get() + val; } inline int operator-(int val) const { return get() - val; } + inline bool operator==(const AtomicInt& other) const { + Raul::barrier(); + return _val == other._val; + } + inline AtomicInt& operator+=(int val) { __sync_fetch_and_add(&_val, val); return *this; diff --git a/raul/AtomicPtr.hpp b/raul/AtomicPtr.hpp index 91c5c35..0dc369b 100644 --- a/raul/AtomicPtr.hpp +++ b/raul/AtomicPtr.hpp @@ -38,6 +38,11 @@ public: return static_cast(_val); } + inline bool operator==(const AtomicPtr& other) const { + Raul::barrier(); + return _val == other._val; + } + inline void operator=(T* val) { _val = val; Raul::barrier(); -- cgit v1.2.1