
on Sat Aug 16 2008, Mika Heiskanen
David Abrahams wrote:
on Sat Aug 16 2008, "Eduardo Panisset"
wrote: if( new_use_count == 0 ) { dispose(); weak_release(); } How Can I ensure that the release member function wouldn't dispose a pointee more than one time ? (release executing concurrently from different shared_ptr instances)
Because the reference count was 1, there can be only one shared_ptr instance that owns the pointee. No other threads can be referencing it.
But since the mutex is released, a copy could be created before the new_use_count test is reached? Or is it impossible to create a copy if use_count_ is zero?
What thread can create a copy? We know exactly what the only thread that has a reference to the owned object is doing (it's executing the very code we're concerned with). -- Dave Abrahams BoostPro Computing http://www.boostpro.com