Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-03-19 15:50:39

Frank Mori Hess:

> On Wednesday 19 March 2008 08:39 am, Peter Dimov wrote:
>> After a brief consideration I think I agree with your approach, though.
>> Nothing better comes to mind. But it would be nice if the deleter
>> replacement happens only if shared_from_this has been called.
> I think that could be done, but would probably require a mutex to protect
> against shared_from_this() getting called concurrently with ownership
> transfer.

I'm not sure. The intended use case is to call shared_from_this from the
constructor, which is being called from:

    shared_ptr<X> px( new X );

I can think of contrived examples where X::X passes the shared_ptr to
another thread which converts it to raw pointer and then calls
shared_from_this again... but I think that we can postpone handling such
cases unless and until they arise.

>> , and another that tests the new behavior.
> I can add some stuff to shared_from_this_test.cpp that calls
> shared_from_this
> from constructors.

No, the new functionality should have its own separate test.

> Regarding the get_deleter breakage, I think I can modify
> sp_counted_impl_pd/sp_counted_impl_pda so their get_deleter methods try to
> unwrap the deleter D if it is of type detail::deleter_wrapper (a class I'm
> currently using as the deleter for the shared_from_this pointers ).

This, too, can probably wait.

Boost list run by bdawes at, gregod at, cpdaniel at, john at