Subject: Re: [boost] [Memory Managed Pointer] Review Request
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-04-27 07:18:03
Phil Bouchard wrote:
> On 4/26/2011 4:20 PM, Phil Bouchard wrote:
> > On 4/26/2011 3:34 PM, Matthew Chambers wrote:
> > I'm careful selecting the right word but so far mutual_ptr
> > wins because it means what it means and won't clash with
> > other keywords.
> I renamed it once more to mutual_ptr and I added a caveat to
> the documentation. It is accessible here:
I think until the naming noise settles, you'd be better off not renaming your class, updating the documentation, or sending messages with yet another name in the subject line. You've gone through, what, ten iterations now?
My initial understanding of your class, is that it is a reference counting smart pointer with additional scaffolding, including an allocator, to couple the reference count together with the payload. That much, at least, is like boost::shared_ptr when constructed using boost::make_shared(), as pointed out previously by Nevin, IIRC. So far, your class is little different than shared_ptr, except that you've forced the equivalent of boost::make_shared() without its safety (you require a bald new) or convenience (the new expression is for a distinct type which requires naming the payload type a second time in all uses) to create your pointer type.
I found your rationale.html, so I now understand that you manage a counter to track when your pointers refer to blocks of memory and not, in order to know when to release memory. Apparently, there are two reference counts then. The first is in the smart pointer to know a datum is unreferenced and the other to know when no data in what you term a "set" is being referenced. What's a bit confusing is that you depict three pointers referring to one "set" which has a count of just one. Presumably, this is because you use some non-portable technique to determine stack versus free store allocation so that only stack-based allocations modify the "set" count.
At any rate, the really unique aspect of your smart pointer class is the memory management. If I understand correctly, you allocate memory from blocks such that when all memory from a block has been released, you release the block too. Thus, the payload for your smart pointer comes from such a block and when there are no stack-based pointers referring to a block, it, and all other smart pointers referring to it, will be released.
Assuming I have understood your design reasonably correctly, then the "block allocation" mechanism is the unique feature and suggests the name "block_ptr."
BTW, s/instanciate/instantiate/ and s/subdivise/subdivide/ in your docs.
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk