diff options
author | Thiago Macieira <thiago@kde.org> | 2011-07-31 17:40:40 -0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-20 12:26:26 +0100 |
commit | 1f843ca39ee59c5304009faf308ddce791614a02 (patch) | |
tree | 31e9e0bd87f30ecb26f93846a6380759b231013b /header.LGPL | |
parent | f188d8a005e7c06869aa96bddb82053178c554e9 (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 'header.LGPL')
0 files changed, 0 insertions, 0 deletions