diff options
author | Thiago Macieira <thiago@kde.org> | 2011-07-31 19:33:54 -0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-28 16:54:17 +0100 |
commit | 7c0153faf7664bf0f7e64b578f3d196aae02c328 (patch) | |
tree | ad4d9176b7ff3328c2a3edb1dfea925650f0bf84 /src/corelib/thread | |
parent | 2bbd2262b3974fb4e39341a23e40ffdf1655ebe9 (diff) |
Add a set of atomics based on C++11's std::atomic
The C++11 std::atomic type is very close to our API, to the point one
has to wonder if the committe was inspired by it. It provides all of
the memory semantics that Qt requires and more, plus some
compare-and-swap operations that we don't use.
The idea of returning the actual value in the event of a failed
compare-and-swap is actually quite good, as often we'll retry with
it. We just couldn't come up with a good name (fetchAndTestAndSet?).
The C++11 atomics require that the compiler support constexpr as well,
since std::atomic itself isn't required by the standard to be
trivially-constructible (in fact, it has a constexpr constructor in
the standard). For that reason, we need constexpr so we can add a
constructor to QBasicAtomic too.
Change-Id: I12c51455ba73350a6f7501aacc2ca7681c4369dd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qbasicatomic.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 18febd36de..cb94319f55 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -58,6 +58,8 @@ # include "QtCore/qatomic_mips.h" #elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) # include <QtCore/qatomic_x86_64.h> +#elif defined(Q_COMPILER_ATOMICS) && defined(Q_COMPILER_CONSTEXPR) +# include <QtCore/qatomic_cxx0x.h> #elif defined(Q_CC_GNU) # include <QtCore/qatomic_gcc.h> #else |