New shared pointer - revision 2
Mirko Boehm
mirko at kde.org
Sat Sep 10 17:24:22 BST 2005
On Saturday 10 September 2005 04:32, Frerich Raabe wrote:
> based on your feedback, I modificated the previously presented shared
> pointer a little:
>
> - All functions are documented now. In particular, get() got a warning
> which explains that the reference counting is circumvented, so you better
> be careful.
> - Inspired by a comment from Adriaan, I added a 'detach()' function which
> detaches a pointer. 'p.detach();' is simply nicer than 'p = p.copy();'
> - As requested by Thiago. Instead of an int, QAtomic is used as the type
> for the reference count. Pointer assignments are done via qAtomicSetPtr.
> This hopefully improves thread-safety.
>
> I also added a little testcase which exercises all functions a little bit
> and checks whether certain assertions still hold.
I would like to state the obvious here: Since mit is a shared pointer, make
sure the class is thread-safe (which is not trivial). The reference counting
has to work acros thread boundaries.
Everybody who attended akademy has seen me evangelizing on this topic :-)
--Mirko.
--
KDE e.V.: http://www.kde.org/areas/kde-ev/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050910/807338dc/attachment.sig>
More information about the kde-core-devel
mailing list