summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qoldbasicatomic.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago@kde.org>2011-07-31 17:40:40 -0300
committerQt by Nokia <qt-info@nokia.com>2012-01-20 12:26:26 +0100
commit1f843ca39ee59c5304009faf308ddce791614a02 (patch)
tree31e9e0bd87f30ecb26f93846a6380759b231013b /src/corelib/thread/qoldbasicatomic.h
parentf188d8a005e7c06869aa96bddb82053178c554e9 (diff)
Add the new QBasicAtomicXXX implementation - no backends yet
The new implementation is API- and ABI-compatible with the old implementation, provided that QBasicAtomicInt isn't used as an argument in a function call or the return value: now, QBasicAtomicInt is a typedef to QBasicAtomicInteger<int>. The new design is based on CRTP: the QGenericAtomicOps template class takes as a template parameter the derived class itself. This way, we implement a "poor man's virtual" without a virtual table and everything is inline. QGenericAtomicOps implements most of the atomics code that is repeated in many classes all over: * Acquire semantics are obtained by placing an acquire barrier after the Relaxed operation * Release semantics are obtained by placing a release barrier before the Relaxed operation * Ordered semantics are obtained by placing an ordered barrier before the Relaxed operation (either way would be fine) * fetchAndStoreRelaxed and fetchAndAddRelaxed are implemented on top of testAndSetRelaxed * ref and deref are implemented on top of fetchAndAddRelaxed It also adds load, loadAcquire, store and storeRelease: the default implementations of loadAcquire and storeRelease operate on a volatile variable and add barriers. There are no direct operators for accessing the value. Each architecture-specific implementation can override any of the functions or the memory barrier functions. It must implement at least the testAndSetRelaxed function. In addition, by specialising one template class, the implementations can allow QBasicAtomicInteger for additional types (of different sizes). At the very least, int, unsigned and pointers must be supported. Change-Id: I6da647e225bb330d3cfc16f84d0e7849dff85ec7 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src/corelib/thread/qoldbasicatomic.h')
-rw-r--r--src/corelib/thread/qoldbasicatomic.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/thread/qoldbasicatomic.h b/src/corelib/thread/qoldbasicatomic.h
index 2f952c9e0a..114615d1d2 100644
--- a/src/corelib/thread/qoldbasicatomic.h
+++ b/src/corelib/thread/qoldbasicatomic.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QBASICATOMIC_H
-#define QBASICATOMIC_H
+#ifndef QOLDBASICATOMIC_H
+#define QOLDBASICATOMIC_H
#include <QtCore/qglobal.h>
@@ -50,6 +50,11 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
+#if 0
+#pragma qt_no_master_include
+#pragma qt_sync_stop_processing
+#endif
+
class Q_CORE_EXPORT QBasicAtomicInt
{
public: