src/corelib/thread/qatomic.h File Reference

#include <QtCore/qatomic_arch.h>
#include <QtCore/qglobal.h>

Include dependency graph for qatomic.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  QBasicAtomic
struct  QBasicAtomicPointer< T >
class  QAtomic
class  QAtomicPointer< T >

Defines

#define Q_ATOMIC_INIT(a)   { (a) }

Functions

template<typename T>
qAtomicSetPtr (volatile T *ptr, T newval)
template<typename T>
void qAtomicAssign (T *&d, T *x)
template<typename T>
void qAtomicAssign (QBasicAtomicPointer< T > &d, T *x)
template<typename T>
void qAtomicAssign (QBasicAtomicPointer< T > &d, const QBasicAtomicPointer< T > &x)
template<typename T>
void qAtomicDetach (T *&d)
template<typename T>
void qAtomicDetach (QBasicAtomicPointer< T > &d)


Define Documentation

#define Q_ATOMIC_INIT (  )     { (a) }

Definition at line 143 of file qatomic.h.


Function Documentation

template<typename T>
void qAtomicAssign ( QBasicAtomicPointer< T > &  d,
const QBasicAtomicPointer< T > &  x 
) [inline]

Definition at line 230 of file qatomic.h.

References d, and x.

00231 { qAtomicAssign<T>(d, x); }

template<typename T>
void qAtomicAssign ( QBasicAtomicPointer< T > &  d,
T *  x 
) [inline]

Definition at line 218 of file qatomic.h.

References d.

00219 {
00220     x->ref.ref();
00221     x = d.exchange(x);
00222     if (!x->ref.deref())
00223         delete x;
00224 }

template<typename T>
void qAtomicAssign ( T *&  d,
T *  x 
) [inline]

This is a helper for the assignment operators of implicitly shared classes. Your assignment operator should look like this:

        MyClass &MyClass:operator=(const MyClass &other)
        { qAtomicAssign(d, other.d); return *this; }

Definition at line 206 of file qatomic.h.

References qAtomicSetPtr().

Referenced by QColormap::operator=(), QDateTime::operator=(), QFileInfo::operator=(), QPen::operator=(), QCursor::operator=(), QUrl::operator=(), QDBusMessage::operator=(), QSqlDatabase::operator=(), QFontMetricsF::operator=(), QKeySequence::operator=(), QFontMetrics::operator=(), QSqlQuery::operator=(), QSqlField::operator=(), QFontInfo::operator=(), QFont::operator=(), QDir::operator=(), and QSqlRecord::operator=().

00207 {
00208     x->ref.ref();
00209     x = qAtomicSetPtr(&d, x);
00210     if (!x->ref.deref())
00211         delete x;
00212 }

Here is the call graph for this function:

template<typename T>
void qAtomicDetach ( QBasicAtomicPointer< T > &  d  )  [inline]

Definition at line 258 of file qatomic.h.

References d, T, and x.

00259 {
00260     if (d->ref == 1)
00261         return;
00262     T *x = new T(*d);
00263     x = d.exchange(x);
00264     if (!x->ref.deref())
00265         delete x;
00266 }

template<typename T>
void qAtomicDetach ( T *&  d  )  [inline]

Definition at line 244 of file qatomic.h.

References qAtomicSetPtr(), T, and x.

Referenced by QFileInfoPrivate::detach(), QDirPrivate::detach(), QDateTime::detach(), QSqlRecord::detach(), QSqlField::detach(), QFont::detach(), QUrl::detach(), operator>>(), and QKeySequence::setKey().

00245 {
00246     if (d->ref == 1)
00247         return;
00248     T *x = new T(*d);
00249     x = qAtomicSetPtr(&d, x);
00250     if (!x->ref.deref())
00251         delete x;
00252 }

Here is the call graph for this function:

template<typename T>
T qAtomicSetPtr ( volatile T *  ptr,
newval 
) [inline]

Definition at line 148 of file qatomic.h.

References q_atomic_set_ptr().

Referenced by QVariant::detach(), QListData::detach(), QPalette::detach(), QPen::detach(), QBrush::detach(), QMap< Key, T >::detach_helper(), QLinkedList< T >::detach_helper(), QPainterPath::detach_helper(), QPicture::detach_helper(), QGLColormap::detach_helper(), QHash< Key, T >::detach_helper(), QSharedDataPointer< T >::detach_helper(), QPainterPath::ensureData_helper(), QDBusArgument::operator=(), QExplicitlySharedDataPointer< TranslationUnitData >::operator=(), QPainterPath::operator=(), QDomNamedNodeMap::operator=(), QTextDocumentFragment::operator=(), QList< T >::operator=(), QLinkedList< T >::operator=(), QPalette::operator=(), QIcon::operator=(), QBrush::operator=(), QByteArray::operator=(), QMap< Key, T >::operator=(), QX11Info::operator=(), QSharedDataPointer< QStyleSheetPaletteData >::operator=(), QString::operator=(), QVector< T >::operator=(), QHash< Key, T >::operator=(), QGLColormap::operator=(), QDomImplementation::operator=(), QDomNodeList::operator=(), QDomNode::operator=(), QImage::operator=(), qAtomicAssign(), qAtomicDetach(), QString::realloc(), QByteArray::realloc(), QVector< T >::realloc(), QByteArray::resize(), QString::resize(), QCursor::setShape(), and QList< T >::~QList().

00149 { return static_cast<T>(q_atomic_set_ptr(ptr, newval)); }

Here is the call graph for this function:


Generated on Thu Mar 15 12:48:14 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1