Boost logo

Boost :

Subject: Re: [boost] [valid_ptr] proposing a new type of pointer object that allows validity tracking without memory management and object ownership
From: Gruenke, Matt (mgruenke_at_[hidden])
Date: 2011-03-17 12:30:25


-----Original Message-----
From: boost-bounces_at_[hidden] on behalf of Dan Walters
Sent: Thu 3/17/2011 8:21 AM
To: boost_at_[hidden]
Subject: Re: [boost] [valid_ptr] proposing a new type of pointer object that allows validity tracking without memory management and object ownership
 
On 17 March 2011 03:33, Gruenke, Matt <mgruenke_at_[hidden]> wrote:
...

> Matt <mgruenke_at_[hidden]> wrote:
> the same thing could be accomplished by using weak pointers to an
> object whose refcount had been manually incremented by 1.  When you
> want to kill it, one of the referers could then manually decrement the
> refcount, so that it gets killed when it goes back to idle.
>
> valid_ptr should not be able to release it's target object by design -
> it is not a memory management pointer.

It doesn't matter whether valid_ptr can be used to delete the object. The point was that in order to fulfill the contract of ensuring that the pointer is valid while used, in a threadsafe fashion, it would need to either hold a lock or a reference count preventing the object from being deleted while an expression involving one of the access operators is being evaluated.

As you point out, valid_ptr doesn't need to solve the problem of thread synchronization in order to be usable in a multithreaded environment. However, if it doesn't, the question is whether it provides enough value that people would use it.

Matt


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk