2016-09-08 18:57 GMT+02:00 Konstantin Shegunov <kshegu...@gmail.com>:
>
>
> On Thu, Sep 8, 2016 at 7:50 PM, Elvis Stansvik <elvst...@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. ;)

Ah yes, my mistake :) I of course meant QSharedDataPointer.

>>
>>
>> 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.

Hm, okay. Perhaps a dumb question, but what are the consequences
internal vs external refcounting for me as a user of these classes?
Reading the docs for both of them, both seem to have a thread-safe
refcounting mechanism.

>
>>
>> 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.

Ah, that's a good point I hadn't thought of.

>
>>
>> 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 see, so could this be the main reason for QESDP's existance (which I
didn't see at first)? The use-case is the same as for the implicit
variant, only when you want more control over when detach happens?
Could you give some example of when you really want that kind of
control?

Elvis

>
> I hope that helps.

Yep, thanks a lot.

Elvis

> Kind regards.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to