[Interest] QExplictlySharedDataPointer vs QSharedPointer
Thiago Macieira
thiago.macieira at intel.com
Thu Sep 8 20:33:45 CEST 2016
On quinta-feira, 8 de setembro de 2016 19:13:44 PDT Elvis Stansvik wrote:
> 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.
The difference is, quite literally, where the reference counter lives.
If it's inside the object whose lifetime it controls, then the reference
counter cannot outlive the object itself. That means an internal reference
counting cannot have QWeakPointer. If the reference count lives outside of the
object, then QWeakPointer is possible.
Also, for the reference counter to live inside the object, the class needs to
have been designed with that in mind.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list