[Interest] reference counting
Sean Harmer
sean.harmer at kdab.com
Sun Nov 16 19:46:50 CET 2014
On Sunday 16 November 2014 19:02:19 René J.V. Bertin wrote:
> On Sunday November 16 2014 18:47:34 Giuseppe D'Angelo wrote:
> > Most of the value classes are implicitly shared:
> >
> > http://qt-project.org/doc/qt-5/implicit-sharing.html
>
> Yes, I saw that doc (also in Qt4). What kind of sharing does this refer to -
> across threads and/or only across owners in a same thread? ObjC's reference
> counting basically determines the lifetime of an object (and prevents the
> need for a "deleteLater" operator).
QSharedPointer?
> But the main thing I'm curious about:
> is this implicit sharing mechanism thread safe and if so, do you (thus) use
> some kind of interlocked increment/decrement of the reference counter?
An atomic integer is used. See for e.g. QVector which uses QArrayData which in
turn uses QtPrivate::RefCount which in turn uses QBasicAtomicInt.
Cheers,
Sean
--
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
More information about the Interest
mailing list