#include
<QtCore/qglobal.h>#include <QtCore/qbasicatomic.h>Go to the source code of this file.
Classes |
|
| class | QAtomicInt |
| class | QAtomicPointer< T > |
Functions |
|
| template<typename T > | |
| void | qAtomicAssign (T *&d, T *x) |
| This is a helper for the assignment
operators of implicitly shared classes. |
|
| template<typename T > | |
| void | qAtomicDetach (T *&d) |
| This is a helper for the detach method of
implicitly shared classes. |
|
| void qAtomicAssign | ( | T *& | d, |
| T * | x | ||
| ) | [inline] |
| void qAtomicDetach | ( | T *& | d | ) | [inline] |
This is a helper for the detach method of implicitly shared classes.
Your private class needs a copy constructor which copies the members and sets the refcount to 1. After that, your detach function should look like this:
doc/src/snippets/code/src.corelib.thread.qatomic.h 1
Definition at line 214 of file qatomic.h.
{
if (d->ref == 1)
return;
T *x = d;
d = new T(*d);
if (!x->ref.deref())
delete x;
}