New shared pointer - revision 2
Frerich Raabe
raabe at kde.org
Sat Sep 10 03:32:00 BST 2005
Hi,
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.
- Frerich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ksharedptr.h
Type: text/x-c++hdr
Size: 6467 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050910/c88ead09/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ksharedptrtest.cc
Type: text/x-c++src
Size: 737 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050910/c88ead09/attachment.cc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050910/c88ead09/attachment.sig>
More information about the kde-core-devel
mailing list