Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: Eyeballs needed on new reference counted pointer template

From: Warren Young <mysqlpp(at)etr-usa.com>
Date: Thu Aug 16 2007 - 05:31:48 EDT


Alex Burton wrote:
> Slight improvements might be made by only testing counted_ to know if it
> is a non null pointer instead of checking ref_ is set all the time.

This is just paranoia, of the same sort that motivates some other posters in this thread to recommend zeroing the pointers in detach(). I think they're right to be paranoid, because it justifies my own paranoia. :)

You never know when some bug will cause one pointer but not the other to be zeroed. If either is zero, we can't dereference the other, because it's not supposed to be used any more.

An earlier iteration simplified all this by wrapping both the reference count and the T* in a structure, and RefCountedPointer actually managed a pointer to a structure of this type on the heap. It had the advantage of only one data member in RefCountedPointer itself, so only one thing to test, but it turned the single indirection of an unmanaged pointer into triple indirection. Too expensive...

-- 
MySQL++ Mailing List
For list archives: 
http://lists.mysql.com/plusplus
To unsubscribe:    
http://lists.mysql.com/plusplus?unsub=lists@pantek.com
Received on Thu Aug 16 12:42:55 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 10:03:02 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library