
On Wed, 2008-04-23 at 08:45 -0400, Frank Mori Hess wrote:
The comment is obsolete, now that the pointer value is calculated in the shared_from_this() calls. Yes, the deleter_wrapper only needs a shared_count.
The comment suggest that the lazy initialization is just a work-around for the more desirable initialization during the ctor. Is this no longer true?
And what I was getting at before, _internal_shared_count could be made a local variable in init_internal_shared_once(), if you add a line where you stuff it inside its own deleter_wrapper. Anywhere else it is used, it can be obtained from _internal_weak_count.
I think we should pick the low-hanging fruits first. If it's OK for you I'll apply the attached patch. Next thing I'd like to address is getting rid of the _owner flag, I think it should be possible. We are then left with an overhead of the vtable and two plain pointers (inside of shared_count and weak_count). For the vtable, we could remove it by switching shared_from_this from a member function to a free function that takes T* as a parameter, but that's of course a breaking change... Regards, Daniel