[Interest] QExplictlySharedDataPointer vs QSharedPointer
Konstantin Shegunov
kshegunov at gmail.com
Thu Sep 8 18:57:20 CEST 2016
On Thu, Sep 8, 2016 at 7:50 PM, Elvis Stansvik <elvstone at gmail.com> wrote:
> Hi all,
> QSharedData and QImplicitlySharedDataPointer (QISDP) is a common
> combination used to implement implicit sharing, both in Qt itself and
> in Qt-using projects.
>
QSharedDataPointer, the implicit part is implicit. ;)
>
> I'm curious about the role/use for QESDP compared to QSharedPointer.
> The main differences I can see is
>
QESDP has internal reference counting while QSharedPointer utilizes
external reference counting.
> But regarding this second difference, wouldn't it be easy enough to
> just take the raw pointer to the underlying object with data(), and
> make a copy of that?
>
Thread safety isn't guaranteed in that case.
> In short, I fail to see a strong use case for QESDP compared to using
> a QSharedPointer. I'm probably missing something.
>
> Does anyone know of a code base that makes liberal use of QESDP, or
> could you share how you're making use of it?
>
I use the explicit variant for the same thing as the implicit, thus all
consideration apply, with the minor exception that I have manual control
over the data copying.
I hope that helps.
Kind regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160908/766d475d/attachment.html>
More information about the Interest
mailing list